Code Monkey home page Code Monkey logo

lori's Introduction

Lori

Pony TCP classes reimagined.

Status

vs-ponyc-latest

This is an experimental project and shouldn't be used in a production environment.

Installation

  • Install corral
  • corral add github.com/seantallen/lori.git
  • corral fetch to fetch your dependencies
  • use "lori" to include this package
  • corral run -- ponyc to compile your application

Example

Server

actor Main
  new create(env: Env) =>
    try
      let auth = TCPListenAuth(env.root as AmbientAuth)
      TCPListener(auth, None, {():None => None} val)
      .> on(DATA, {(c: TCPConnection ref, d: Array[U8] iso) => c.send(consume d) })
      .> listen("0.0.0.0", 7669)
    end

Client

actor Main
  new create(env: Env) =>
    try
      let auth = TCPConnectAuth(env.root as AmbientAuth)
      TCPConnection(auth, None)
      .> on(CONN, {(self: TCPConnection ref) =>self.send("Hello!")})
      .> on(DATA, {(self: TCPConnection ref, d: Array[U8] iso) => self.log(consume d) })
      .> start("127.0.0.1", 7669, "localhost")
    end

Ping-Pong

actor Main
  new create(env: Env) =>
    try
      // auth
      let listen_auth = TCPListenAuth(env.root as AmbientAuth)
      let conn_auth = TCPConnectAuth(env.root as AmbientAuth)

      // server
      TCPListener(listen_auth, None, {():None=> None})
      .> on(DATA, {(conn: TCPConnection ref, data: Array[U8] iso) =>
           conn.log(consume data)
           conn.send("Pong") })
      .> listen("0.0.0.0", 7670)

      // client
      let cli = TCPConnection(conn_auth, None)
      .> on(CONN, {(self: TCPConnection ref) => self.send("Ping")})
      .> on(DATA, {(self: TCPConnection ref,  data: Array[U8] iso) =>
           self.log(consume data)
           self.send("Ping") })
      .> start("127.0.0.1", 7670, "")
    end

lori's People

Contributors

seantallen avatar damon-kwok avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.