Esempio n. 1
0
 private static void TextMessageUser_OnTextUserMessage(string message, Credentials sourceuser)
 {
     if (OnPrivateMessage != null)
     {
         OnPrivateMessage(sourceuser, message);
     }
 }
Esempio n. 2
0
 private static void TextMessageRoom_OnTextMessage(string roomname, string message, Credentials sourceuser)
 {
     ClientManager.LogData("<" + sourceuser.Name + ":" + roomname + "> " + message);
     if (OnChatroomMessage != null)
     {
         OnChatroomMessage(sourceuser, roomname, message);
     }
 }
Esempio n. 3
0
 private void Gatherings_OnPrivateMessage(Credentials sourceuser, string message)
 {
     lock (this.mMessages)
     {
         if (message.StartsWith("/"))
         {
             this.mMessages.Enqueue(message);
         }
         else
         {
             this.mMessages.Enqueue("<" + sourceuser.Name + "> " + message);
         }
     }
 }
Esempio n. 4
0
 private static void ReceiveCallback(IAsyncResult ar)
 {
     try
     {
         StateObject asyncState = (StateObject) ar.AsyncState;
         Socket workSocket = asyncState.workSocket;
         if (workSocket.Connected && !asyncState.ConnectionError)
         {
             int length = 0;
             try
             {
                 length = workSocket.EndReceive(ar);
             }
             catch (ObjectDisposedException)
             {
                 asyncState.ConnectionError = true;
                 ClientManager.LogData("A connection has been disposed and is no longer valid.");
                 return;
             }
             catch (SocketException)
             {
                 asyncState.ConnectionError = true;
                 ClientManager.LogData("The server has shut down.");
                 if (OnCommandMessage != null)
                 {
                     CommandMessage message = new CommandMessage {
                         CommandName = Commands.TextMessageRoom
                     };
                     Credentials credentials = new Credentials {
                         Name = "Disconnect",
                         PrincipalID = -1
                     };
                     message.SetParams(new object[] { "Disconnect", "Connection to the GPGnet server has been lost.", credentials });
                     OnCommandMessage(asyncState.ConnectionID, message);
                     message.SetParams(new object[] { "Disconnect", "Please restart GPGnet once network connectivity has been restored.", credentials });
                     OnCommandMessage(asyncState.ConnectionID, message);
                 }
                 return;
             }
             if (length > 0)
             {
                 byte[] destinationArray = new byte[length];
                 Array.Copy(asyncState.buffer, destinationArray, length);
                 asyncState.Stream.Position = asyncState.Stream.Length;
                 asyncState.Stream.Write(destinationArray, 0, destinationArray.Length);
                 try
                 {
                     for (CommandMessage message2 = asyncState.GetNextMessage(); message2 != null; message2 = asyncState.GetNextMessage())
                     {
                         if (OnCommandMessage != null)
                         {
                             OnCommandMessage(asyncState.ConnectionID, message2);
                         }
                     }
                 }
                 catch (Exception exception)
                 {
                     asyncState.ResetState();
                     ClientManager.LogData(exception);
                 }
                 workSocket.BeginReceive(asyncState.buffer, 0, 0x1000, SocketFlags.None, new AsyncCallback(MessageBroker.ReceiveCallback), asyncState);
             }
             else
             {
                 asyncState.ConnectionError = true;
                 ClientManager.LogData("Received a 0 byte disconnect from " + asyncState.ConnectionID.ToString());
             }
         }
     }
     catch (Exception exception2)
     {
         ClientManager.LogData(exception2.ToString());
     }
 }
Esempio n. 5
0
 private static void Login_OnLogin(bool loggedin, Credentials credentials)
 {
     sLoginResult = loggedin;
     sLogginIn = false;
 }