private static void AcceptCallback(IAsyncResult ar) { var chanelSocket = serverListenerHandler.EndAccept(ar); var chanel = new Chanel(chanelSocket); chanelSocket.BeginReceive(chanel.Buffer, 0, Chanel.BufferSize, 0, new AsyncCallback(ReadCallback), chanel); }
public int Add(Chanel chanel) { int id = count; chanels.Add(count, chanel); count++; return(id); }
private static void AcceptCallback(IAsyncResult ar) { allDone.Set(); var listener = (Socket)ar.AsyncState; var clientSocket = listener.EndAccept(ar); var chanel = new Chanel(clientSocket); Console.WriteLine("client connected: " + SocketLogger.ChanelInfo(chanel)); clientSocket.BeginReceive(chanel.Buffer, 0, Chanel.BufferSize, 0, new AsyncCallback(ReadCallback), chanel); }
private static void Send(Chanel chanel, object result) { var data = Serializer.Serialize(result); chanel.ChanelHandler.BeginSend(data, 0, data.Length, 0, new AsyncCallback(SendCallback), chanel); }