Example #1
0
 /// <summary>
 /// Send Packet to everyone but sender
 /// </summary>
 public void SendPacket(CString Packet, NCConnection Sender)
 {
     /*
     List<NCConnection> _tmpNCList = new List<NCConnection>();
     foreach (NCConnection nc in NCList)
     {
         _tmpNCList.Add(nc);
     }
     */
     lock (NCList)
     {
         foreach (NCConnection nc in NCList)
         {
             if (nc != Sender)
             {
                 if (nc.Connected)
                 {
                     Console.WriteLine("[NCOUT]: " + Packet.ToString());
                     nc.SendPacket(Packet, true);
                 }
                 //else Console.WriteLine("Failed to send data to NC!");
             }
         }
     }
     //_tmpNCList.Clear ();
     //_tmpNCList = null;
 }
Example #2
0
        /// <summary>
        /// Accept incoming connection for NPC-Control
        /// </summary>
        /// <param name="ar"></param>
        protected void NCControl_Accept(IAsyncResult ar)
        {
            // Accept Socket
            NCConnection Client = new NCConnection (this, (Socket)NCListen.EndAcceptSocket (ar));
            Client.ReceiveData ();
            NCList.Add (Client);

            // Listen for incoming connections
            NCListen.BeginAcceptSocket (cNCAccept, NCListen);
        }
Example #3
0
 public void SendNCChat(String Message, NCConnection From)
 {
     SendPacket (new CString () + (byte)NCConnection.PacketOut.NC_CHAT + Message, From);
 }