示例#1
0
 /// <summary>
 /// Begin async write from client
 /// </summary>
 /// <param name="src">Receiver's Id</param>
 /// <param name="ct">NetPacket command type</param>
 /// <param name="data">Data bytes</param>
 public void BeginWriteToClient(int src, NetPacket.PacketType ct, byte[] data)
 {
     NetPacket packet = new NetPacket(src, this._clientId, ct, data);
     Thread t = new Thread(this.StartWriteSync);
     t.Name = "ServerStartWriteSync";
     t.Start(packet);
 }
示例#2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="endPoint">Specifies endpoint of sender</param>
 /// <param name="msg">Message associated with event</param>
 /// <param name="_packet">Packet received</param>
 /// <param name="exception">Any exception, if occured</param>
 public NetEventArgs(EndPoint endPoint, string msg, NetPacket _packet, Exception exception)
 {
     this._endPoint = endPoint;
     this._msg = msg;
     this._packet = _packet;
     this._exception = exception;
 }
示例#3
0
 /// <summary>
 /// Constructor
 /// </summary>        
 /// <param name="_packet">Packet received</param>        
 public NetEventArgs(NetPacket packet)
     : this(null, null, packet, null)
 {
 }
示例#4
0
 /// <summary>
 /// Constructor
 /// </summary>        
 /// <param name="msg">Message associated with event</param>
 /// <param name="_packet">Packet received</param>        
 public NetEventArgs(NetPacket packet, string msg)
     : this(packet)
 {
     this._msg = msg;
 }
示例#5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="endPoint">Specifies endpoint of sender</param>
 /// <param name="msg">Message associated with event</param>
 /// <param name="_packet">Packet received</param>        
 public NetEventArgs(EndPoint endPoint, string msg, NetPacket packet)
     : this(endPoint, msg)
 {
     this._packet = packet;
 }
示例#6
0
 /// <summary>
 /// Deserialize NetPacket
 /// </summary>
 /// <param name="obj">Data bytes</param>
 private void UnsealPacket(object obj)
 {
     NetPacket packet = new NetPacket();
     packet.Deserialize(obj as byte[]);
     switch (packet.Header.Type)
     {
         case NetPacket.PacketType.Command:
             this.ParseCommand(packet.Data);
             break;
         default:
             if (this.OnClientDataReceived != null)
             {
                 NetEventArgs e = new NetEventArgs(packet);
                 this.OnClientDataReceived(this._tcpClient, e);
             }
             break;
     }
 }
示例#7
0
 /// <summary>
 /// Gets the sender's name from the network packet by referecing the name table
 /// </summary>
 /// <param name="packet">NetPacket containing the header</param>
 /// <returns>Sender's name</returns>
 public string GetSenderName(NetPacket packet)
 {
     return this._clientNames[packet.Header.Source];
 }
示例#8
0
 /// <summary>
 /// Gets the receiver's name from the network packet by referecing the name table
 /// </summary>
 /// <param name="packet">NetPacket containing the header</param>
 /// <returns>Sender's name</returns>
 public string GetReceiverName(NetPacket packet)
 {
     return this._clientNames[packet.Header.Destination];
 }
示例#9
0
 /// <summary>
 /// Performs a write to client using the service of client manager
 /// </summary>
 /// <param name="dest">Client Id</param>
 /// <param name="ct">NetPacket command type</param>
 /// <param name="data">Data bytes</param>
 public void BeginWriteToClient(int dest, NetPacket.PacketType ct, byte[] data)
 {
     this._clientManager[dest].BeginWriteToClient(0, ct, data);
 }
示例#10
0
 public void BeginWriteToClient(int dest, NetPacket.PacketType ct, byte[] data)
 {
     NetPacket packet = new NetPacket(this._id, dest, ct, data);
     Thread t = new Thread(this.StartWriteSync);
     t.Name = "StartWriteSync";
     t.Start(packet);
 }