public Context(SocketController controller) { _controller = controller; _size = new ByteTransmitter(controller.Socket, 4); _size.OnReceived += new ReceivedEvent(_size_OnReceived); _size.BeginReceive(); }
void OnConnect(IAsyncResult res) { var server = (TcpListener)res.AsyncState; var socket = server.EndAcceptSocket(res); var ctx = new SocketController(socket); ctx.OnMessage += new MessageEvent(ctx_OnMessage); server.BeginAcceptSocket(new AsyncCallback(OnConnect), server); }
public MessageClient(string host, int port) { _bus = new MessageBus(); _client = new TcpClient(); _client.Connect(host, port); var ctx = new SocketController(_client.Client); _controller = ctx; ctx.OnMessage += new MessageEvent(ctx_OnMessage); }