public void LoginCallBack(ClientResponse response)
    {
        if (watingPanel != null)
        {
            watingPanel.SetActive(false);
        }

        SoundCtrl.getInstance().playBGM();
        if (response.status == 1)
        {
            if (GlobalDataScript.homePanel != null)
            {
                GlobalDataScript.homePanel.GetComponent <HomePanelScript> ().removeListener();
                Destroy(GlobalDataScript.homePanel);
            }


            if (GlobalDataScript.gamePlayPanel != null)
            {
                GlobalDataScript.gamePlayPanel.GetComponent <MyMahjongScript> ().exitOrDissoliveRoom();
            }

            GlobalDataScript.loginResponseData = JsonMapper.ToObject <AvatarVO> (response.message);
            ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid));
            panelCreateDialog = Instantiate(Resources.Load("Prefab/Panel_Home")) as GameObject;
            panelCreateDialog.transform.parent     = GlobalDataScript.getInstance().canvsTransfrom;
            panelCreateDialog.transform.localScale = Vector3.one;
            panelCreateDialog.GetComponent <RectTransform>().offsetMax = new Vector2(0f, 0f);
            panelCreateDialog.GetComponent <RectTransform>().offsetMin = new Vector2(0f, 0f);
            GlobalDataScript.homePanel = panelCreateDialog;
            removeListener();
            Destroy(this);
            Destroy(gameObject);
        }
    }
Example #2
0
    /// <summary>
    /// 异步连接的回调函数
    /// </summary>
    /// <param name="ar"></param>
    private void ConnectCallback(IAsyncResult ar)
    {
        //connectDone.Set();
        if ((tcpclient != null) && (tcpclient.Connected))
        {
            stream = tcpclient.GetStream();
            asyncread(tcpclient);
            MyDebug.Log("--chatSocketUrl-------ConnectCallback-----聊天服务器已经连接---");
            MyDebug.Log("聊天服务器已经连接!");
            //	showMessageTip ("聊天服务器已经连接!");
        }
        else
        {
            MyDebug.Log("--chatSocketUrl-------ConnectCallback----已经断开连接---");
            closeSocket();
            return;
        }
        TcpClient t = (TcpClient)ar.AsyncState;

        try
        {
            t.EndConnect(ar);
        }
        catch (Exception ex)
        {
            //设置标志,连接服务端失败!
            Debug.Log(ex.ToString());
        }

        if (!init)
        {
            init = true;
            ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid));
        }
    }
Example #3
0
    public void login()
    {
        MyDebug.Log("----------------1-------------------");
        if (!CustomSocket.getInstance().isConnected)
        {
            CustomSocket.getInstance().Connect();
            ChatSocket.getInstance().Connect();
            tapCount = 0;
            MyDebug.Log("----------------2------------------");
            return;
        }

        GlobalDataScript.reinitData();         //初始化界面数据
        if (agreeProtocol.isOn)
        {
            MyDebug.Log("----------------3------------------");
            doLogin();
            watingPanel.GetComponentInChildren <Text>().text = "进入游戏中";
            watingPanel.SetActive(true);
        }
        else
        {
            MyDebug.Log("请先同意用户使用协议");
            TipsManagerScript.getInstance().setTips("请先同意用户使用协议");
        }

        tapCount += 1;
        Invoke("resetClickNum", 10f);
    }
Example #4
0
    IEnumerator ConnectTime1(float time, byte type)
    {
        connectRetruen = false;

        if (watingPanel != null)
        {
            watingPanel.SetActive(true);
            watingPanel.GetComponentInChildren <Text> ().text = "正在连接服务器...";
        }

        CustomSocket.hasStartTimer = false;
        CustomSocket.getInstance().Connect();
        ChatSocket.getInstance().Connect();
        GlobalDataScript.isonLoginPage = true;

        yield return(new WaitForSeconds(time));

        if (!connectRetruen)          //超过5秒还没连接成功显示失败
        {
            if (type == 1)
            {
                watingPanel.SetActive(false);
            }
            else if (type == 2)
            {
            }
        }
    }
    public float StopRecord()
    {
        if (micArray.Length == 0)
        {
            return(0);
        }
        if (!Microphone.IsRecording(null))
        {
            return(0);
        }
        int lastTime = Microphone.GetPosition(null);

        Microphone.End(null);
        if (lastTime <= 0)
        {
            return(0);
        }
        float[] samples = new float[redioclip.samples];         //
        redioclip.GetData(samples, 0);
        float[] clipSamples = new float[lastTime];
        Array.Copy(samples, clipSamples, clipSamples.Length - 1);
        redioclip = AudioClip.Create("playRecordClip", clipSamples.Length, 1, 8000, false);
        redioclip.SetData(clipSamples, 0);

        SoundCtrl.playAudio.clip = redioclip;
        ChatSocket.getInstance().sendMsg(new MicInputRequest(userList, GetClipData()));
        PlayRecord();
        return(redioclip.length);
    }
    public void login()
    {
        if (!CustomSocket.getInstance().isConnected)
        {
            CustomSocket.getInstance().Connect();
            ChatSocket.getInstance().Connect();
            tapCount = 0;
            return;
        }



        GlobalDataScript.reinitData();         //初始化界面数据
        if (agreeProtocol.isOn)
        {
            doLogin();
            watingPanel.SetActive(true);
        }
        else
        {
            MyDebug.Log("请先同意用户使用协议");
            TipsManagerScript.getInstance().setTips("请先同意用户使用协议");
        }

        tapCount += 1;
        Invoke("resetClickNum", 10f);
    }
    private void RoomBackResponse(ClientResponse response)
    {
        watingPanel.SetActive(false);

        if (GlobalDataScript.homePanel != null)
        {
            GlobalDataScript.homePanel.GetComponent <HomePanelScript> ().removeListener();
            Destroy(GlobalDataScript.homePanel);
        }


        if (GlobalDataScript.gamePlayPanel != null)
        {
            GlobalDataScript.gamePlayPanel.GetComponent <MyMahjongScript> ().exitOrDissoliveRoom();
        }
        GlobalDataScript.reEnterRoomData = JsonMapper.ToObject <RoomJoinResponseVo> (response.message);

        for (int i = 0; i < GlobalDataScript.reEnterRoomData.playerList.Count; i++)
        {
            AvatarVO itemData = GlobalDataScript.reEnterRoomData.playerList [i];
            if (itemData.account.openid == GlobalDataScript.loginResponseData.account.openid)
            {
                GlobalDataScript.loginResponseData.account.uuid = itemData.account.uuid;
                ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid));
                break;
            }
        }

        GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GamePlay");
        removeListener();
        Destroy(this);
        Destroy(gameObject);
    }
Example #8
0
 private static void sendHeartbeat()
 {
     if (CustomSocket.getInstance().isConnected)
     {
         CustomSocket.getInstance().sendHeadData();
         ChatSocket.getInstance().sendHeadData();
     }
     Thread.Sleep(20000);
     sendHeartbeat();
 }
Example #9
0
    public GameObject watingPanel; //正在登陆,请稍候


    void Start()
    {
        CustomSocket.getInstance().hasStartTimer = false;
        CustomSocket.getInstance().Connect();
        ChatSocket.getInstance().Connect();
        GlobalDataScript.isonLoginPage = true;
        SocketEventHandle.getInstance().TestMesgCallBack += TestMesgCallBack;
        SocketEventHandle.getInstance().LoginCallBack    += LoginCallBack;
        SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse;
        versionText.text = "版本号:" + Application.version;
    }
Example #10
0
 void Start()
 {
     CustomSocket.getInstance().hasStartTimer = false;
     CustomSocket.getInstance().Connect();
     ChatSocket.getInstance().Connect();
     GlobalDataScript.isonLoginPage = true;
     SocketEventHandle.getInstance().LoginCallBack       += LoginCallBack;
     SocketEventHandle.getInstance().LoginWeChatCallBack += LoginWeChatCallBack;
     SocketEventHandle.getInstance().RoomBackResponse    += RoomBackResponse;
     PlatformBridge.Instance.WeChatLoginListener += WeChatLoginCallBack;
     versionText.text = "版本号:" + Application.version;
 }
 void Start()
 {
     //shareSdk.showUserHandler = getUserInforCallback;//注册获取用户信息回调
     CustomSocket.hasStartTimer = false;
     CustomSocket.getInstance().Connect();
     ChatSocket.getInstance().Connect();
     GlobalDataScript.isonLoginPage = true;
     SocketEventHandle.getInstance().LoginCallBack    += LoginCallBack;
     SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse;
     versionText.text = "版本号:" + Application.version;
     //WxPayImpl test = new WxPayImpl(gameObject);
     //test.callTest ("dddddddddddddddddddddddddddd");
 }
Example #12
0
 public void StopRecord()
 {
     MyDebug.Log("StopRecord");
     if (micArray.Length == 0)
     {
         Debug.Log("No Record Device!");
         return;
     }
     if (!Microphone.IsRecording(null))
     {
         return;
     }
     Microphone.End(null);
     GetComponent <AudioSource>().Stop();
     ChatSocket.getInstance().sendMsg(new MicInputRequest(userList, GetClipData()));
     PlayRecord();
 }
Example #13
0
    IEnumerator ConnectTime1(float time, byte type)
    {
        connectRetruen = false;
        yield return(new WaitForSeconds(time));

        if (!connectRetruen)
        {//超过5秒还没连接成功显示失败
            if (type == 1)
            {
                CustomSocket.hasStartTimer = false;
                CustomSocket.getInstance().Connect();
                ChatSocket.getInstance().Connect();
                GlobalDataScript.isonLoginPage = true;
            }
            else if (type == 2)
            {
            }
        }
    }
Example #14
0
    public void loginWechat()
    {
        SoundCtrl.getInstance().playSoundUI(true);

        if (!CustomSocket.getInstance().isConnected)
        {
            CustomSocket.getInstance().Connect();
            ChatSocket.getInstance().Connect();
            tapCount = 0;
            return;
        }

        GlobalDataScript.reinitData();        //初始化界面数据
        if (agreeProtocol.isOn)
        {
//			doLogin();
            if (Application.platform == RuntimePlatform.OSXEditor ||
                Application.platform == RuntimePlatform.WindowsEditor)
            {
                WeChatLoginCallBack("{\"access_token\":" +
                                    "\"BYl9EIcjwyVFdP3F8ZIo8_OrDlMi4MNKFRDGdl_3KkmtU5YLl7Vgi4dw17I24tS2af2CqhBX6X3p9R5emnZOen8SvuFkNn5_wd4042L3d2w\"," +
                                    "\"expires_in\":7200," +
                                    "\"refresh_token\":" +
                                    "\"BQhqiKHK_cUnED8a1CfRgUcXuS4EyGcq9XQAdj-N-3ctMUoG6VxzTROBIe7m1Q2Ws17br6MJxk85tIbMz4ecsI1VEXsfslh9jyWN1Xjt6vc\"," +
                                    "\"openid\":\"o3LILj-8xTgvce2P_QBjMrgDZdQg\"," +
                                    "\"scope\":\"snsapi_userinfo\"," +
                                    "\"unionid\":\"oHRAHuO86ExIL6tLdyAkFSFlEoYw\"}");
            }
            else
            {
                PlatformBridge.Instance.doWeChatLogin();
                watingPanel.SetActive(true);
            }
        }
        else
        {
            MyDebug.Log("请先同意用户使用协议");
            TipsManagerScript.getInstance().setTips("请先同意用户使用协议");
        }

        tapCount += 1;
        Invoke("resetClickNum", 10f);
    }
Example #15
0
    void Start()
    {
        (this.transform as RectTransform).sizeDelta = new Vector2(1136, 640);

        DOTween.Init(false, true, LogBehaviour.Default);
        if (null != PanelSafeGame)
        {
            PanelSafeGame.GetComponent <CanvasGroup>().DOFade(0, 1.0f).SetDelay(1.0f).OnComplete(FadeOutSafeGame);
        }

        //shareSdk.showUserHandler = getUserInforCallback;//注册获取用户信息回调
        CustomSocket.hasStartTimer = false;
        CustomSocket.getInstance().Connect();
        ChatSocket.getInstance().Connect();
        GlobalDataScript.isonLoginPage = true;
        SocketEventHandle.getInstance().LoginCallBack    += LoginCallBack;
        SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse;
        versionText.text = "版本号:" + Application.version;
        //WxPayImpl test = new WxPayImpl(gameObject);
        //test.callTest ("dddddddddddddddddddddddddddd");
    }
Example #16
0
    void Start()
    {
        CustomSocket.getInstance().hasStartTimer = false;
        CustomSocket.getInstance().Connect();
        ChatSocket.getInstance().Connect();
        GlobalDataScript.isonLoginPage = true;
        SocketEventHandle.getInstance().UpdateGlobalData += UpdateGlobalData;
        SocketEventHandle.getInstance().LoginCallBack    += LoginCallBack;
        SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse;
        versionText.text = "版本号:" + Application.version;

#if UNITY_IPHONE
        canGuestLogin  = GlobalDataScript.inAppPay;
        canWechatLogin = GlobalDataScript.getInstance().wechatOperate.isWechatValid();
        agreement.SetActive(!canGuestLogin);
        guestLogin.SetActive(canGuestLogin);
        if (canGuestLogin)
        {
            wechatLogin.SetActive(canWechatLogin);
        }
#endif
    }
Example #17
0
    private void RoomBackResponse(ClientResponse response)
    {
        if (GlobalDataScript.gamePlayPanel != null)
        {
            GlobalDataScript.gamePlayPanel.GetComponent <MyMahjongScript>().exitOrDissoliveRoom();
        }

        GlobalDataScript.reEnterRoomData = JsonMapper.ToObject <RoomJoinResponseVo>(response.message);

        for (int i = 0; i < GlobalDataScript.reEnterRoomData.playerList.Count; i++)
        {
            AvatarVO itemData = GlobalDataScript.reEnterRoomData.playerList[i];
            if (itemData.account.openid == GlobalDataScript.loginResponseData.account.openid)
            {
                GlobalDataScript.loginResponseData.account.uuid = itemData.account.uuid;
                GlobalDataScript.loginResponseData.isOnLine     = true;
                ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid));
                break;
            }
        }

        GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GamePlay");
    }
Example #18
0
    private void RoomBackResponse(ClientResponse response)
    {
        if (GlobalDataScript.homePanel != null)
        {
            GlobalDataScript.homePanel.GetComponent <HomePanelScript> ().removeListener();
            Destroy(GlobalDataScript.homePanel);
        }
        GlobalDataScript.reEnterRoomData = JsonMapper.ToObject <RoomCreateVo> (response.message);
        GlobalDataScript.goldType        = GlobalDataScript.reEnterRoomData.goldType;

        if (GlobalDataScript.gamePlayPanel != null)
        {
            if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.NULL)
            {
                GlobalDataScript.gamePlayPanel.GetComponent <MyMahjongScript> ().exitOrDissoliveRoom();
            }
            else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.PDK)
            {
                GlobalDataScript.gamePlayPanel.GetComponent <MyPDKScript> ().exitOrDissoliveRoom();
            }
            else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.DN)
            {
                GlobalDataScript.gamePlayPanel.GetComponent <MyDNScript> ().exitOrDissoliveRoom();
            }
            else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.DZPK)
            {
                GlobalDataScript.gamePlayPanel.GetComponent <MyDZPKScript> ().exitOrDissoliveRoom();
            }
            else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.AMH)
            {
                GlobalDataScript.gamePlayPanel.GetComponent <MyDZPKScript>().exitOrDissoliveRoom();
            }
        }

        for (int i = 0; i < GlobalDataScript.reEnterRoomData.playerList.Count; i++)
        {
            AvatarVO itemData = GlobalDataScript.reEnterRoomData.playerList [i];
            if (itemData.account.openid == GlobalDataScript.loginResponseData.account.openid)
            {
                GlobalDataScript.loginResponseData.account.uuid     = itemData.account.uuid;
                GlobalDataScript.loginResponseData.account.roomcard = itemData.account.roomcard;
                GlobalDataScript.loginResponseData.account.gold     = itemData.account.gold;
                GlobalDataScript.loginResponseData.account.isCheat  = itemData.account.isCheat;
                ChatSocket.getInstance().sendMsg(new LoginChatRequest(GlobalDataScript.loginResponseData.account.uuid));
                break;
            }
        }
        if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.NULL)
        {
            GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GamePlay");
        }
        else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.PDK)
        {
            GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GamePDK");
        }
        else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.DN)
        {
            GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GameDN");
        }
        else if (GlobalDataScript.reEnterRoomData.gameType == (int)GameTypePK.DZPK)
        {
            GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GameDZPK");
        }
        else if (GlobalDataScript.roomVo.gameType == (int)GameTypePK.AMH)
        {
            GlobalDataScript.gamePlayPanel = PrefabManage.loadPerfab("Prefab/Panel_GameAMH");
        }

        removeListener();
        Destroy(this);
        Destroy(gameObject);
    }