Example #1
0
        public static void OnLoginSuccessResponse(ref NetworkClient Client, ProcessedPacket Packet)
        {
            string CacheDir = GlobalSettings.Default.DocumentsPath + "CharacterCache\\" + PlayerAccount.Username;

            if (!Directory.Exists(CacheDir))
            {
                Directory.CreateDirectory(CacheDir);

                //The charactercache didn't exist, so send the Unix epoch, which is
                //older than the server's stamp. This will cause the server to send the entire cache.
                PacketSenders.SendCharacterInfoRequest(new DateTime(1970, 1, 1, 0, 0, 0, 0).ToString(CultureInfo.InvariantCulture));
            }
            else
            {
                if (!File.Exists(CacheDir + "\\Sims.cache"))
                {
                    //The charactercache didn't exist, so send the Unix epoch, which is
                    //older than the server's stamp. This will cause the server to send the entire cache.
                    PacketSenders.SendCharacterInfoRequest(new DateTime(1970, 1, 1, 0, 0, 0, 0).ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    string LastDateCached = Cache.GetDateCached();
                    if (LastDateCached == "")
                    {
                        PacketSenders.SendCharacterInfoRequest(new DateTime(1970, 1, 1, 0, 0, 0, 0).ToString(CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        PacketSenders.SendCharacterInfoRequest(LastDateCached);
                    }
                }
            }
        }
Example #2
0
        private void BtnChat3_Click(object sender, EventArgs e)
        {
            if (NetworkFacade.Cities.Count == 0)
            {
                MessageBox.Show("No cityserver online! Disconnecting...");

                Reset();
                ////This doesn't work here, because this is a callback. TODO: Find a work around...
                //NetworkFacade.Client.Disconnect();

                return;
            }

            ChatFrm Chat;

            if (NetworkFacade.Avatars.Count == 2)
            {
                PacketSenders.RequestCityToken(NetworkFacade.Client, NetworkFacade.Avatars[1]);
                Chat = new ChatFrm(NetworkFacade.Avatars[1]);
                Chat.Show();
            }
            else
            {
                PacketSenders.RequestCityToken(NetworkFacade.Client, NetworkFacade.Avatars[2]);
                Chat = new ChatFrm(NetworkFacade.Avatars[2]);
                Chat.Show();
            }

            this.Visible = false;
        }
Example #3
0
 /// <summary>
 /// Client connected to server successfully.
 /// </summary>
 /// <param name="LoginArgs"></param>
 public static void Client_OnConnected(LoginArgsContainer LoginArgs)
 {
     if (!IsReconnect)
     {
         PacketSenders.SendLoginRequest(LoginArgs);
     }
     else
     {
         PacketSenders.SendLoginRequestCity(LoginArgs);
     }
 }
Example #4
0
        private void BtnSend_Click(object sender, EventArgs e)
        {
            if (TxtMessage.Text != string.Empty)
            {
                //Sending an empty string isn't a good idea.
                PacketSenders.BroadcastLetter(NetworkFacade.Client, TxtMessage.Text, "");

                TxtChat.Invoke(new MethodInvoker(delegate
                {
                    TxtChat.Text   += "\r\n" + TxtMessage.Text;
                    TxtMessage.Text = string.Empty;
                }));
            }
        }
Example #5
0
        private void BtnChat2_Click(object sender, EventArgs e)
        {
            if (NetworkFacade.Cities.Count == 0)
            {
                MessageBox.Show("No cityserver online!");

                Reset();
                //This doesn't work here, because this is a callback. TODO: Find a work around...
                //NetworkFacade.Client.Disconnect();

                return;
            }

            ChatFrm Chat = new ChatFrm(NetworkFacade.Avatars[1]);

            Chat.Show();

            //NetworkController.Reconnect();
            //Because BtnChat2 is disabled unless the user has 3 avatars,
            //it means BtnChat2 will always represent NetworkFacade.Avatars[1].
            PacketSenders.RequestCityToken(NetworkFacade.Client, NetworkFacade.Avatars[1]);

            this.Visible = false;
        }
Example #6
0
 public static void _OnLoginSuccessCity(NetworkClient Client, ProcessedPacket Packet)
 {
     Debug.WriteLine("Received LoginSuccessCity!");
     PacketSenders.SendCityToken(Client);
 }