예제 #1
0
        static public void LoadCacheData()
        {
            var UserCacheData = SQLLiteDB.ReadUserCache();

            if (UserCacheData != null)
            {
                User.CacheData.FontSize = UserCacheData.FontSize;
                User.CacheData.UserName = UserCacheData.UserName;
                User.CacheData.Passwd   = UserCacheData.Passwd;
            }
            else
            {
#if GLOBAL
                User.CacheData.BibleName = "Genesis";
#else
#endif
            }
        }
예제 #2
0
        static public void Loop()
        {
            if (client.socket == null || client.socket.Connected == false)
            {
                return;
            }

            CompletePacket data;

            if (client.PacketQueue.TryDequeue(out data) == true)
            {
                try
                {
                    switch (data.Protocol)
                    {
                    case (int)PROTOCOL.IdPktVersionRes:
                    {
                        VERSION_RES res = new VERSION_RES();
                        res = VERSION_RES.Parser.ParseFrom(data.Data);

                        var currentVersion = VersionTracking.CurrentVersion;

                        double myversion;
                        if (double.TryParse(currentVersion, out myversion) == false)
                        {
                        }

                        const Double Eps = 0.000000000000001;

                        User.Version = res.VarVersion;

                        if (Math.Abs(res.VarVersion - myversion) > Eps)
                        {
                            //첫 검수라 임시 주석 2번째 패치 부터는 활성화
                            if (Device.RuntimePlatform == Device.Android && User.OnceVersionNotify == false)
                            {
                                Device.BeginInvokeOnMainThread(() =>
                                    {
                                        User.OnceVersionNotify = true;
                                        DependencyService.Get <MethodExt>().Notification("New Version Updated");
                                    });
                            }
                        }

                        SQLLiteDB.LoadCacheData();
                        if (User.NickName != null)
                        {
                            NetProcess.SendLogin(User.Uid, User.Token);
                        }
                    }
                    break;

                    case (int)PROTOCOL.IdPktLoginRes:
                    {
                        LOGIN_RES res = new LOGIN_RES();
                        res = LOGIN_RES.Parser.ParseFrom(data.Data);

                        var mainpage = (MainPage)Application.Current.MainPage;

                        if (res.VarCode == ErrorCode.Success)
                        {
                            Xamarin.Forms.DependencyService.Register <MethodExt>();

                            DependencyService.Get <MethodExt>().Notification("New Version Updated");

                            User.LoginSuccess = true;
                            SQLLiteDB.Upsert(res.VarName, "");

                            if (PopupNavigation.Instance.PopupStack.Count > 0)
                            {
                                PopupNavigation.Instance.PopAsync();
                            }
                        }
                        else
                        {
                            Device.BeginInvokeOnMainThread(() =>
                                {
                                });

                            User.LoginSuccess = false;
                        }
                    }
                    break;

                    case (int)PROTOCOL.IdPktRoomListRes:
                    {
                        ROOM_LIST_RES res = new ROOM_LIST_RES();
                        res = ROOM_LIST_RES.Parser.ParseFrom(data.Data);

                        Device.BeginInvokeOnMainThread(() =>
                            {
                                var mainpage = (MainPage)Application.Current.MainPage;
                            });
                    }
                    break;

                    case (int)PROTOCOL.IdPktNoticeRes:
                    {
                        NOTICE_RES res = new NOTICE_RES();
                        res = NOTICE_RES.Parser.ParseFrom(data.Data);

                        Device.BeginInvokeOnMainThread(() =>
                            {
                                var mainpage = (MainPage)Application.Current.MainPage;
                            });
                    }
                    break;

                    case (int)PROTOCOL.IdPktRegCameraRes:
                    {
                        REG_CAMERA_RES res = new REG_CAMERA_RES();
                        res = REG_CAMERA_RES.Parser.ParseFrom(data.Data);

                        Device.BeginInvokeOnMainThread(() =>
                            {
                                var mainpage = (MainPage)Application.Current.MainPage;
                            });
                    }
                    break;

                    case (int)PROTOCOL.IdPktCameraListRes:
                    {
                        CAMERA_LIST_RES res = new CAMERA_LIST_RES();
                        res = CAMERA_LIST_RES.Parser.ParseFrom(data.Data);

                        if (res.VarCode == ErrorCode.Success)
                        {
                            Device.BeginInvokeOnMainThread(() =>
                                {
                                    var mainpage = (MainPage)Application.Current.MainPage;

                                    PopupNavigation.Instance.PushAsync(new CameraListPage(res.VarCamera));
                                });
                        }
                    }
                    break;

                    case (int)PROTOCOL.IdPktMailListRes:
                    {
                        MAIL_LIST_RES res = new MAIL_LIST_RES();
                        res = MAIL_LIST_RES.Parser.ParseFrom(data.Data);
                    }
                    break;

                    case (int)PROTOCOL.IdPktPrayMessageRes:
                    {
                    }
                    break;

                    case (int)PROTOCOL.IdPktCameraWakeUpRes:
                    {
                        CAMERA_WAKE_UP_RES res = new CAMERA_WAKE_UP_RES();
                        res = CAMERA_WAKE_UP_RES.Parser.ParseFrom(data.Data);

                        TargetPlayerId.Add(res.VarToPlayerId);

                        if (PopupNavigation.Instance.PopupStack.Count == 0)
                        {
                            PopupNavigation.Instance.PushAsync(new CameraPage());
                        }
                        else
                        {
                            if (PopupNavigation.Instance.PopupStack[0].GetType() != typeof(CameraPage))
                            {
                                PopupNavigation.Instance.PopAsync();
                                PopupNavigation.Instance.PushAsync(new CameraPage());
                            }
                        }
                    }
                    break;

                    case (int)PROTOCOL.IdPktStopStreamRes:
                    {
                        STOP_STREAM_RES res = new STOP_STREAM_RES();
                        res = STOP_STREAM_RES.Parser.ParseFrom(data.Data);

                        TargetPlayerId.Remove(res.VarToPlayerId);
                    }
                    break;

                    case (int)PROTOCOL.IdPktCreateRoomRes:
                    {
                        CREATE_ROOM_RES res = new CREATE_ROOM_RES();
                        res = CREATE_ROOM_RES.Parser.ParseFrom(data.Data);

                        if (res.VarCode != ErrorCode.Success)
                        {
                            break;
                        }

                        Device.BeginInvokeOnMainThread(() =>
                            {
                                var mainpage = (MainPage)Application.Current.MainPage;


                                User.RoomIdList.Add(res.VarRoomId);

                                {
                                }
                            });
                    }
                    break;

                    case (int)PROTOCOL.IdPktEnterRoomRes:
                    {
                        ENTER_ROOM_RES res = new ENTER_ROOM_RES();
                        res = ENTER_ROOM_RES.Parser.ParseFrom(data.Data);

                        if (res.VarCode != ErrorCode.DuplicateEnterRoom && res.VarCode != ErrorCode.Success)
                        {
                            break;
                        }

                        Device.BeginInvokeOnMainThread(() =>
                            {
                                try
                                {
                                    var mainpage = (MainPage)Application.Current.MainPage;
                                }
                                catch (Exception e)
                                {
                                }
                            });
                    }
                    break;

                    case (int)PROTOCOL.IdPktRoomPassThroughRes:
                    {
                        ROOM_PASS_THROUGH_RES res = new ROOM_PASS_THROUGH_RES();
                        res = ROOM_PASS_THROUGH_RES.Parser.ParseFrom(data.Data);
                        Device.BeginInvokeOnMainThread(() =>
                            {
                                var mainpage = (MainPage)Application.Current.MainPage;
                            });
                    }
                    break;

                    case (int)PROTOCOL.IdPktLeaveRoomRes:
                    {
                        LEAVE_ROOM_RES res = new LEAVE_ROOM_RES();
                        res = LEAVE_ROOM_RES.Parser.ParseFrom(data.Data);

                        var mainpage = (MainPage)Application.Current.MainPage;

                        Device.BeginInvokeOnMainThread(() =>
                            {
                            });
                    }
                    break;

                    case (int)PROTOCOL.IdPktAudioMessageRes:
                    {
                        AUDIO_MESSAGE_RES res = new AUDIO_MESSAGE_RES();
                        res = AUDIO_MESSAGE_RES.Parser.ParseFrom(data.Data);

                        foreach (var msg in res.VarMessage)
                        {
                            StreamWrapper wra = new StreamWrapper();
                            wra.stream = new MemoryStream(msg.ToByteArray());
                            wra.pos    = res.VarPos;
                            AudioStream.Enqueue(wra);
                        }
                    }
                    break;

                    case (int)PROTOCOL.IdPktBitmapMessageRes:
                    {
                        BITMAP_MESSAGE_RES res = new BITMAP_MESSAGE_RES();
                        res = BITMAP_MESSAGE_RES.Parser.ParseFrom(data.Data);

                        foreach (var msg in res.VarMessage)
                        {
                            StreamWrapper wra = new StreamWrapper();
                            wra.stream = new MemoryStream(msg.ToByteArray());
                            JpegStream.Enqueue(wra);
                        }
                    }
                    break;

                    case (int)PROTOCOL.IdPktMpeg2TsMessageRes:
                    {
                        MPEG2TS_MESSAGE_RES res = new MPEG2TS_MESSAGE_RES();
                        res = MPEG2TS_MESSAGE_RES.Parser.ParseFrom(data.Data);

                        foreach (var msg in res.VarMessage)
                        {
                            StreamWrapper wra = new StreamWrapper();
                            wra.stream = new MemoryStream(msg.ToByteArray());
                            wra.type   = res.VarType;
                            Mpeg2Stream.Enqueue(wra);
                        }
                    }
                    break;

                    case (int)PROTOCOL.IdPktNewUserInRoomNty:
                    {
                        NEW_USER_IN_ROOM_NTY res = new NEW_USER_IN_ROOM_NTY();
                        res = NEW_USER_IN_ROOM_NTY.Parser.ParseFrom(data.Data);

                        var mainpage = (MainPage)Application.Current.MainPage;
                    }
                    break;
                    }
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                }
            }
        }