protected void SetupSocket() { socket = new TcpClientWrapper(20); socket.ConnectionEstablished += new TcpClientWrapper.ConnectionEstablishedDelegate(socket_ConnectionEstablished); socket.ConnectionRefused += new TcpClientWrapper.ConnectionRefusedDelegate(socket_ConnectionRefused); socket.Disconnected += new TcpClientWrapper.DisconnectedDelegate(socket_Disconnected); socket.DataRead += new TcpClientWrapper.DataReadDelegate(socket_DataRead); packet = new Packet(); packet.DataSent += new Packet.SendDataDelegate(packet_DataSent); bufferer = new PacketBufferer(SendDataFinal, null, 100); }
public User(TcpClientWrapper clientSocket, bool isConsole) { socket = clientSocket; _isConsole = isConsole; packet = new Packet(); packet.skipHeaders = isConsole; packet.DataSent += new Packet.SendDataDelegate(packet_SendData); bufferer = new PacketBufferer(SendDataFinal, null, Config.SendBufferInterval); Flags = UserFlags.Normal; }
public User(TcpClientWrapper clientSocket, bool isConsole) { socket = clientSocket; _isConsole = isConsole; packet = new Packet(); packet.skipHeaders = isConsole; packet.DataSent += new Packet.SendDataDelegate(packet_SendData); PacketSendBufferer.AddSendHandler(this, SendDataFinal); recvBufferer = new PacketBuffer(); Flags = UserFlags.Normal; }
private void button1_Click(object sender, RoutedEventArgs e) { lock (sockets) { for (int i = 0; i < 10; i++) { TcpClientWrapper sock = new TcpClientWrapper(20); sock.ConnectionEstablished += new TcpClientWrapper.ConnectionEstablishedDelegate(sock_ConnectionEstablished); sock.DataRead += new TcpClientWrapper.DataReadDelegate(sock_DataRead); Packet pack = new Packet(); pack.DataSent += new Packet.SendDataDelegate(pack_DataSent); PacketBufferer bufferer = new PacketBufferer(SendDataFinal, sock, 100); sockets.Add(pack, sock); packets.Add(sock, pack); buffers.Add(sock, bufferer); sock.AsyncConnect("127.0.0.1", 4800); } } }
void pack_DataSent(Packet packet, ref byte[] data) { buffers[sockets[packet]].QueuePacket(ref data); }
private void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { socket = null; packet = null; bufferer = null; Channel = null; } disposed = true; } }
protected void packet_SendData(Packet packet, ref byte[] data) { if (!_canSendData) return; if (!_isConsole) bufferer.QueuePacket(ref data); }
protected void packet_DataSent(Packet packet, ref byte[] data) { bufferer.QueuePacket(ref data); }
private void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { socket.Client.Dispose(); socket = null; packet = null; PacketSendBufferer.RemoveSendHandler(this); recvBufferer = null; Channel = null; } disposed = true; } }