Beispiel #1
0
        internal void NotifyStatusChange(NetConnection conn, NetConnectionStatus previousStatus, string reason)
        {
            if (StatusChanged != null)
            {
                NetStatusEventArgs e = new NetStatusEventArgs();
                e.PreviousStatus = previousStatus;
                e.Connection     = conn;
                e.Reason         = reason;

                StatusChanged(this, e);
            }
        }
Beispiel #2
0
 void StatusChanged(object sender, NetStatusEventArgs e)
 {
     // e.Connection is the connection for which status changed
     // e.Connectionn.Status is the new status
     // e.Reason is a human readable reason for the status change
     if (e.Connection.Status == NetConnectionStatus.Connected)
     {
         System.Console.WriteLine("Status: " + e.Connection.Status.ToString());
         NetMessage outMsg = new NetMessage();
         //Client.SendMessage(outMsg, NetChannel.ReliableUnordered); // <- for example
     }
 }
        void server_StatusChanged(object sender, NetStatusEventArgs e)
        {
            if (e.Connection.Status == NetConnectionStatus.Connecting)
            {
                NetMessage msg = new NetMessage();
                msg.Write("Hello Client, I See you are able to talk to me," +
                    " I Can Talk to you Too!");

                //Sending the packet in Reliable is okay for this because its
                //one packet, When sending lots and lots of data you need to
                //set this to Unreliable. This will garentee it arrives but
                //not in a sepcific order.
                server.SendMessage(msg, e.Connection, NetChannel.ReliableUnordered);

            }
            if (e.Connection.Status == NetConnectionStatus.Disconnected)
            {
                this.Window.Title = "Client Has Disconnected to You";
            }
        }
Beispiel #4
0
      static void Client_StatusChanged(object sender, NetStatusEventArgs e)
      {
         Log.Info(e.Connection + ": " + e.Connection.Status + " - " + e.Reason);

         // If just connected, begin login procedure
         if (e.Connection.Status == NetConnectionStatus.Connected)
         {            
            Program.ChatApplicationBusiness.AskLogin(MainForm.Player, BBMessage.Version);            
         }
         // If connection drops, inform user and get back to the login form
         else if (e.Connection.Status == NetConnectionStatus.Disconnected)
         {
            try // The following fails if application is exiting
            {
               PList = new PlayerList();
               Program.ChatApplicationBusiness.OutputSystemText("Disconnected ! Reason : " + e.Reason, null);
               MainForm.Connect();
            }
            catch { }
         }

      }
        void client_StatusChanged(object sender, NetStatusEventArgs e)
        {
            if (e.Connection.Status == NetConnectionStatus.Connected)
            {
                NetMessage msg = new NetMessage();
                msg.Write("Hello Server! I Am Connected And Able To Communicate!");
                client.SendMessage(msg, NetChannel.ReliableUnordered);

            }
            if (e.Connection.Status == NetConnectionStatus.Disconnected)
            {
                this.Window.Title = "We Were disconnected";
            }
        }
Beispiel #6
0
      public void Server_StatusChanged(object sender, NetStatusEventArgs e)
      {
         // If a client disconnects, delete it from the list
         switch (e.Connection.Status)
         {
            case NetConnectionStatus.Disconnected:
               if (e.Connection.Tag != null)
               {
                  int id = PlayerList.GetPlayerID(e.Connection);
                  Log.Info("Client " + id + " disconnected : " + e.Reason);

                  // Notify other clients
                  BBMessage msg_back = new BBMessage();
                  msg_back.MsgDelPlayer(id, e.Reason);
                  BroadcastMsgExcept(msg_back.GetNetMessage(), NetChannel.ReliableUnordered, id);

                  // Notify
                  NotifyClientDisconnected(e.Connection);
                  // Delete the player from our list
                  PList.DelPlayer(PlayerList.GetPlayerID(e.Connection));
               }
               break;

            default:
               // display changes
               Log.Info(e.Connection + ": " + e.Connection.Status + " - " + e.Reason);
               break;
         }
      }
Beispiel #7
0
 /// <summary>
 /// Handles changes in connection status.
 /// </summary>
 private void SpiderNet_StatusChangedHandler(object Sender, NetStatusEventArgs e)
 {
     switch(e.Connection.Status){
         case NetConnectionStatus.Connected:
             clients.Add(e.Connection.RemoteEndpoint.Address);
             break;
         case NetConnectionStatus.Disconnected:
             Console.Out.WriteLine("someone left the game, yo!");
             clients.Remove(e.Connection.RemoteEndpoint.Address);
             disconnectQueue.Enqueue(e.Connection.RemoteEndpoint.Address);
             break;
         default:
             break;
     }
 }
Beispiel #8
0
 private void StatusChanged(object sender, NetStatusEventArgs e)
 {
     m_log.Info(e.Connection + ": " + e.Connection.Status + " - " + e.Reason);
 }
Beispiel #9
0
        internal void NotifyStatusChange(NetConnection conn, NetConnectionStatus previousStatus, string reason)
        {
            if (StatusChanged != null)
            {
                NetStatusEventArgs e = new NetStatusEventArgs();
                e.PreviousStatus = previousStatus;
                e.Connection = conn;
                e.Reason = reason;

                StatusChanged(this, e);
            }
        }
Beispiel #10
0
        void OnStatusChange(object sender, NetStatusEventArgs e)
        {
            m_log.Info(e.Connection + ": " + e.Connection.Status + " - " + e.Reason);
            if (e.Connection.Status == NetConnectionStatus.Connected)
            {
                NetMessage outMsg = new NetMessage();
                outMsg.Write("MSG:Server:Welcome:0.01:" + m_players.Count);
                Server.SendMessage(outMsg, e.Connection, NetChannel.Unreliable);
                NetPlayer ins = new NetPlayer(e.Connection, "");
                m_players.Add(ins);
                Console.WriteLine("Client connected; " + Server.NumConnected + " of 100");

            }

            if (e.Connection.Status == NetConnectionStatus.Disconnected)
            {
                //HaveDeconnection = true;
                //RemoveDeconnectedPlayer();
                for (int i = 0; i < m_players.Count; i++)
                {
                    NetPlayer tmp = m_players[i];
                    if (tmp.PlayerConnection == e.Connection)
                    {
                        if (tmp.CurrentRoom != null)
                        {
                            tmp.CurrentRoom.Send("ROM:PLAYER:LEAVE:" + tmp.GetName(), null);
                            tmp.CurrentRoom.RemovePlayer(tmp);
                        }
                        m_players.Remove(tmp);
                    }
                }
            }
        }