Created
March 18, 2017 00:15
-
-
Save waratuman/308b7890de35efe9027cc965fcbf0a0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use "net" | |
actor Main | |
let _userList: PcUser tag = PcUser | |
new create(env: Env) => | |
try | |
TCPListener( | |
env.root as AmbientAuth, | |
PcNetTcpListenNotifier(_userList), | |
"", | |
"8080" | |
) | |
end | |
actor PcUser | |
let _userList: Array[String] ref = Array[String] | |
be add(userName: String) => | |
_userList.push(userName) | |
be writeSize(conn: TCPConnection tag) => | |
conn.write(_userList.size().string()) | |
class PcNetTcpListenNotifier is TCPListenNotify | |
var _user: PcUser tag | |
new iso create(user: PcUser tag) => | |
_user = user | |
fun ref connected(listen: TCPListener ref): TCPConnectionNotify iso^ => | |
PcNetTcpConnectionNotifier(_user) | |
class PcNetTcpConnectionNotifier is TCPConnectionNotify | |
var _user: PcUser tag | |
new iso create(user: PcUser tag) => | |
_user = user | |
fun ref received(conn: TCPConnection ref, data: Array[U8] iso): Bool => | |
_user.add("abc") | |
_user.writeSize(conn) | |
false | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment