예제 #1
0
 public Context(SocketController controller)
 {
     _controller       = controller;
     _size             = new ByteTransmitter(controller.Socket, 4);
     _size.OnReceived += new ReceivedEvent(_size_OnReceived);
     _size.BeginReceive();
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }