Пример #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            mainPage = new MainPage();

            CSocket = new ClientSocket(IPAddress.Parse("209.141.53.112"), 25050);
            CSocket.ClientSocketConnected_Event += new EventHandler(CSocket_ClientSocketConnected_Event);
            CSocket.ClientSocketDisconnected_Event += new EventHandler(CSocket_ClientSocketDisconnected_Event);
            CSocket.ClientSocketPacketReceived_Event += new ClientSocketPacketReceived_Handler(CSocket_ClientSocketPacketReceived_Event);
            CSocket.Connect();

            this.RootVisual = mainPage;
        }
Пример #2
0
        void HandleUpdateChangeDeliver(ClientSocket clientSocket, Packet pak)
        {
            this.Dispatcher.Invoke((MethodInvoker)delegate
            {
                int MemberID = pak.Readint();
                string NewStatusUpdate = pak.Readstring();

                Contacts[MemberID].control.txt_Status.Text = NewStatusUpdate;
                Contacts[MemberID].StatusUpdate = NewStatusUpdate;
            }, null);
        }
Пример #3
0
        void HandleStatusChangeDeliver(ClientSocket clientSocket, Packet pak)
        {
            this.Dispatcher.Invoke((MethodInvoker)delegate
            {
                int MemberID = pak.Readint();
                Status NewStatus = (Status)pak.Readbyte();
                Contact contact = Contacts[MemberID];

                if (contact.status == Status.Offline && NewStatus != Status.Offline && ConfigManager.Instance.GetBool("txt_loginnotification", true) && ConfigManager.Instance.GetBool("txt_notifications", true))
                    NotificationWindow.ShowNotification(String.Format("{0} Has Signed In", contact.FullName), String.Format("{0} has just signed in.", contact.FullName), contact);
                if (contact.status != Status.Offline && NewStatus == Status.Offline && ConfigManager.Instance.GetBool("txt_logoutnotification", true) && ConfigManager.Instance.GetBool("txt_notifications", true))
                {
                    VCallCore.EndCall(contact.ID);
                    NotificationWindow.ShowNotification(String.Format("{0} Has Signed Out", contact.FullName), String.Format("{0} has just signed out.", contact.FullName), contact);
                }

                contact.status = NewStatus;
                BlazeGames.IM.Client.MainWindow.Instance.page_Contacts.Draw();
            }, null);
        }
Пример #4
0
        void HandleMessageDeliver(ClientSocket clientSocket, Packet pak)
        {
            this.Dispatcher.Invoke((MethodInvoker)delegate
            {
                int FromMemberID = pak.Readint();
                string Message = pak.Readstring();

                if(BlazeGames.IM.Client.MainWindow.Instance.page_Chat.ChattingWith != null)
                    if (BlazeGames.IM.Client.MainWindow.Instance.page_Chat.ChattingWith.ID == FromMemberID)
                        BlazeGames.IM.Client.MainWindow.Instance.page_Chat.HandleMessage(Contacts[FromMemberID].FullName, Message);

                Contacts[FromMemberID].ReceiveNewMessage(Message);
            }, null);
        }
Пример #5
0
        void HandleMemberInfoResponse(ClientSocket clientSocket, Packet pak)
        {
            this.Dispatcher.Invoke((MethodInvoker)delegate
            {
                    ReceivedFriendCount++;

                    if (pak.Readbool())
                    {
                        int MemberID = pak.Readint();
                        string MemberNickname = pak.Readstring();
                        string MemberStatus = pak.Readstring();
                        int MemberAuth = pak.Readint();
                        byte StatusCode = pak.Readbyte();
                        bool PendingRequest = pak.Readbool();
                        string FirstName = pak.Readstring();
                        string LastName = pak.Readstring();

                        if (!Contacts.ContainsKey(MemberID))
                            Contacts.Add(MemberID, new Contact(MemberID, MemberNickname, FirstName, LastName, PendingRequest, (Status)StatusCode, MemberStatus, MemberAuth));
                        else
                        {
                            Contact contact = Contacts[MemberID];

                            contact.NickName = MemberNickname;
                            contact.StatusUpdate = MemberStatus;
                            contact.Authority = MemberAuth;
                            contact.status = (Status)StatusCode;
                            contact.Pending = PendingRequest;
                            contact.FirstName = FirstName;
                            contact.LastName = LastName;
                            contact.FullName = FirstName + " " + LastName;
                        }

                        if (PendingRequest && ConfigManager.Instance.GetBool("txt_newrequestnotification", true) && ConfigManager.Instance.GetBool("txt_notifications", true))
                        {
                            NotificationWindow.ShowNotification("Pending Contact", String.Format("{0} has requested you be added to their contact list.", MemberNickname));
                        }

                        if (ReceivedFriendCount >= FriendCount)
                            BlazeGames.IM.Client.MainWindow.Instance.page_Contacts.Draw();
                    }

                    if (ReceivedFriendCount == FriendCount)
                        clientSocket.SendPacket(Packet.New(Packets.PAK_CLI_OFFLNMSGRQST));
            }, null);
        }
Пример #6
0
        void HandleLoginResponse(ClientSocket clientSocket, Packet pak)
        {
            bool LoginValid = pak.Readbool();

            if (LoginValid)
            {
                string nickname = pak.Readstring();
                string StatusUpdate = pak.Readstring();
                string FullName = pak.Readstring();

                clientSocket.SendPacket(Packet.New(Packets.PAK_CLI_FRNDLSTRQST));
                this.Dispatcher.Invoke((MethodInvoker)delegate
                {
                    Account = BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_account.Text;
                    Password = BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_password.Password;
                    NickName = nickname;
                    App.FullName = FullName;

                    BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_loading.Content = "Fetching Your Contacts";
                    BlazeGames.IM.Client.MainWindow.Instance.txt_nickname.Text = nickname;
                    //BlazeGames.IM.Client.MainWindow.Instance.txt_nickname.Effect = new System.Windows.Media.Effects.BlurEffect();
                    BlazeGames.IM.Client.MainWindow.Instance.txt_status.Text = StatusUpdate;
                    CurrentStatus = Status.Online;

                    BlazeGames.IM.Client.MainWindow.Instance.profile_image_source.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri("https://blaze-games.com/api/image/nocompress/?nickname=" + nickname), new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore));
                }, null);
            }
            else
            {
                this.Dispatcher.Invoke((MethodInvoker)delegate
                {
                    byte ResponseByte = pak.Readbyte();

                    if (ResponseByte == 0x01)
                        NotificationWindow.ShowNotification("Unable to login", "Blaze Games IM was unable to verify this account, please check your username and password and try again.");
                    else if(ResponseByte == 0x02)
                        NotificationWindow.ShowNotification("Unable to login", "This account is already connected, please sign out and try again.");
                    else
                        MessageBox.Show("o.O", "Login Failed");

                    BlazeGames.IM.Client.MainWindow.Instance.page_Login.btn_login.Visibility = Visibility.Visible;
                    BlazeGames.IM.Client.MainWindow.Instance.page_Login.Loading.Visibility = Visibility.Hidden;
                    BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_loading.Visibility = Visibility.Hidden;
                    BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_account.Visibility = Visibility.Visible;
                    BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_password.Visibility = Visibility.Visible;
                }, null);
            }
        }
Пример #7
0
        void HandleFriendRemoveDeliver(ClientSocket clientSocket, Packet pak)
        {
            this.Dispatcher.Invoke((MethodInvoker)delegate
            {
                int MemberID = pak.Readint();

                if (Contacts.ContainsKey(MemberID))
                    Contacts.Remove(MemberID);

                BlazeGames.IM.Client.MainWindow.Instance.page_Contacts.Draw();
            }, null);
        }
Пример #8
0
        void HandleFriendListResponse(ClientSocket clientSocket, Packet pak)
        {
            int FriendsCount = pak.Readint();
            FriendCount = FriendsCount;

            for (int i = 0; i < FriendsCount; i++)
            {
                    int FriendID = pak.Readint();
                    try
                    {
                        clientSocket.SendPacket(Packet.New(Packets.PAK_CLI_MEMINFORQST, FriendID));
                    }
                    catch(Exception ex) { Console.WriteLine(ex.ToString()); }

            }

            this.Dispatcher.Invoke((MethodInvoker)delegate
            {
                LoginComplete = true;
                BlazeGames.IM.Client.MainWindow.Instance.txt_nickname.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.txt_status.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.txt_search.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.profile_image.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.nav_bar.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.listbox1.Visibility = Visibility.Visible;

                BlazeGames.IM.Client.MainWindow.Instance.btn_ProfileSettings.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.btn_AddFriend.Visibility = Visibility.Visible;

                BlazeGames.IM.Client.MainWindow.Instance.btn_chat.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.btn_close.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.btn_contacts.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.btn_home.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.btn_minimize.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.btn_settings.Visibility = Visibility.Visible;
                SlideFade.StartAnimationIn(BlazeGames.IM.Client.MainWindow.Instance.wnd);

                BlazeGames.IM.Client.MainWindow.Instance.page_Login.Visibility = Visibility.Hidden;
                BlazeGames.IM.Client.MainWindow.Instance.page_Home.Visibility = System.Windows.Visibility.Visible;
                SlideFade.StartAnimationIn(BlazeGames.IM.Client.MainWindow.Instance.page_Home);

                BlazeGames.IM.Client.MainWindow.Instance.page_Login.btn_login.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.page_Login.Loading.Visibility = Visibility.Hidden;

                BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_loading.Visibility = Visibility.Hidden;
                BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_account.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_password.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.page_Login.txt_loading.Content = "Loading Your Account";
            }, null);
        }
Пример #9
0
        void HandleCallRequest(ClientSocket clientsocket, Packet pak)
        {
            this.Dispatcher.Invoke((MethodInvoker)delegate
            {
                int MemberID = pak.Readint();
                Contact contact = Contacts[MemberID];
                string UDPAddress = pak.Readstring();
                int Port = pak.Readint();

                NotificationWindow.ShowCallNotification(contact, UDPAddress, Port);
            }, null);
        }
Пример #10
0
 void HandleCallDenyRequest(ClientSocket clientsocket, Packet pak)
 {
     this.Dispatcher.Invoke((MethodInvoker)delegate
     {
         int MemberID = pak.Readint();
         Contact contact = Contacts[MemberID];
         contact.CallActive = false;
         VCallCore.EndCall(MemberID);
         SoundManager.VoiceCallingSound.Stop();
         NotificationWindow.RemoveCallNotification(contact);
     }, null);
 }
Пример #11
0
        void HandleCallAcceptRequest(ClientSocket clientsocket, Packet pak)
        {
            this.Dispatcher.Invoke((MethodInvoker)delegate
            {
                int MemberID = pak.Readint();
                string UDPAddress = pak.Readstring();
                int Port = pak.Readint();

                VCallCore.StartCall(MemberID, new IPEndPoint(IPAddress.Parse(UDPAddress), Port));
                SoundManager.VoiceCallingSound.Stop();

            }, null);
        }
Пример #12
0
        void App_Startup(object sender, StartupEventArgs e)
        {
            VCallCore = new VoiceCallCore();

            Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException);

            int StartupTick = Environment.TickCount & Int32.MaxValue;

            CSocket = new ClientSocket(IPAddress.Parse("209.141.53.112"), 25050);
            CSocket.ClientSocketPacketReceived_Event += new ClientSocketPacketReceived_Handler(CSocket_ClientSocketPacketReceived_Event);
            CSocket.ClientSocketConnected_Event += new EventHandler(CSocket_ClientSocketConnected_Event);
            CSocket.ClientSocketDisconnected_Event += new EventHandler(CSocket_ClientSocketDisconnected_Event);
            //CSocket.Connect();

            int InitalizeTick = Environment.TickCount & Int32.MaxValue;

            BlazeGames.IM.Client.MainWindow.Instance.Show();

            int ShowTick = Environment.TickCount & Int32.MaxValue;

            int InitalizeTime = InitalizeTick - ApplicationStartTick;
            int ShowTime = (ShowTick - ApplicationStartTick) - InitalizeTime;
            int StartTime = ShowTick - ApplicationStartTick;
            int NetworkTime = GetPingMS("blaze-games.com");
            DateTime BuildTime = RetrieveLinkerTimestamp();

            if (ConfigManager.Instance.GetBool("indev", false))
            {
                BlazeGames.IM.Client.MainWindow.Instance.txt_debug.Visibility = Visibility.Visible;
                BlazeGames.IM.Client.MainWindow.Instance.txt_debug.Text = String.Format("Ver: PUBLIC_PREVIEW_{4}_{5}    Startup Time: {0}ms    Server Ping Time: {3}ms", StartTime, InitalizeTime, ShowTime, NetworkTime, BuildTime.ToShortDateString(), BuildTime.ToShortTimeString());
                Plugins.PluginsManager.Instance.LoadPluginsFromFolder();
            }

            UpdateCheck();

            System.Timers.Timer UpdateCheckTimer = new System.Timers.Timer(5 * 60 * 1000);
            UpdateCheckTimer.Elapsed += new System.Timers.ElapsedEventHandler(UpdateCheckTimer_Elapsed);
            UpdateCheckTimer.Start();
        }
Пример #13
0
 public void CSocket_ClientSocketPacketReceived_Event(object sender, ClientSocket clientSocket, Packet pak)
 {
     if (pak.IsValid())
     {
         uint PacketHeader = pak.Readuint();
         switch (PacketHeader)
         {
             case Packets.PAK_SRV_LGNRESP: this.HandleLoginResponse(clientSocket, pak); break;
             case Packets.PAK_SRV_FRNDLSTRESP: this.HandleFriendListResponse(clientSocket, pak); break;
             case Packets.PAK_SRV_MEMINFORESP: this.HandleMemberInfoResponse(clientSocket, pak); break;
             case Packets.PAK_SRV_MSGDLVR: this.HandleMessageDeliver(clientSocket, pak); break;
             case Packets.PAK_SRV_NEWSTSDLVR: this.HandleStatusChangeDeliver(clientSocket, pak); break;
             case Packets.PAK_SRV_NEWUPDTDLVR: this.HandleUpdateChangeDeliver(clientSocket, pak); break;
             case Packets.PAK_SRV_FRNDRMVDLVR: this.HandleFriendRemoveDeliver(clientSocket, pak); break;
             case Packets.PAK_SRV_CALL_DLVR: this.HandleCallRequest(clientSocket, pak); break;
             case Packets.PAK_SRV_CALL_ACC_DLVR: this.HandleCallAcceptRequest(clientSocket, pak); break;
             case Packets.PAK_SRV_CALL_DNY_DLVR: this.HandleCallDenyRequest(clientSocket, pak); break;
             default: break;
         }
     }
 }
Пример #14
0
 void CSocket_ClientSocketPacketReceived_Event(object sender, ClientSocket clientSocket, Packet pak)
 {
     mainPage.Dispatcher.BeginInvoke((MethodInvoker)delegate
     {
         MessageBox.Show("Received");
     }, null);
 }