Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     SocketEventHandle.getInstance().JoinRoomCallBack += onJoinRoomCallBack;
     GlobalDataScript.goldType = false;
     inputChars = new List <String>();
     for (int i = 0; i < btnList.Count; i++)
     {
         GameObject gobj = btnList[i];
         btnList[i].GetComponent <Button>().onClick.AddListener(delegate() {
             this.OnClickHandle(gobj);
         });
     }
 }
Esempio n. 2
0
    public void timeout(object source, System.Timers.ElapsedEventArgs e)
    {
        disConnectCount += 1;
        if (disConnectCount >= 15)
        {
            t.Stop();

            disConnectCount = 0;
            isConnected     = false;
            SocketEventHandle.getInstance().noticeDisConect();
            return;
        }
    }
    void Awake()
    {
        SocketEventHandle.getInstance().disConnetNotice        += disConnetNotice;
        SocketEventHandle.getInstance().hostUpdateDrawResponse += hostUpdateDrawResponse;
        SocketEventHandle.getInstance().otherTeleLogin         += otherTeleLogin;
        GlobalDataScript.getInstance().xinTiaoTime              = DateTime.UtcNow;

        if (PlayerPrefs.HasKey("yinyueVolume"))
        {
            GlobalDataScript.yinyueVolume  = PlayerPrefs.GetFloat("yinyueVolume");
            GlobalDataScript.yinxiaoVolume = PlayerPrefs.GetFloat("yinxiaoVolume");
        }
    }
    private void readBuffer(BinaryReader buffers)
    {
        // 协议标记
        byte flag = buffers.ReadByte();
        // 数据总长度
        int lens = ReadInt(buffers.ReadBytes(4));

        disConnectCount = 0;
        if (!hasStartTimer && lens == 16)
        {
            // startTimer(); TODO 超时判断
            hasStartTimer = true;
        }
        if (lens > buffers.BaseStream.Length)
        {
            waitLen = lens;
            isWait  = true;
            buffers.BaseStream.Position = 0;
            byte[] dd   = new byte[buffers.BaseStream.Length];
            byte[] temp = buffers.ReadBytes((int)buffers.BaseStream.Length);
            Array.Copy(temp, 0, dd, 0, (int)buffers.BaseStream.Length);
            if (sources == null)
            {
                sources = dd;
            }
            return;
        }
        // 相应的操作码
        int headcode = ReadInt(buffers.ReadBytes(4));
        // 服务器状态码 成功1 失败-1
        int   status     = ReadInt(buffers.ReadBytes(4));
        short messageLen = ReadShort(buffers.ReadBytes(2));

        Debug.Log("开始解析数据");
        Debug.Log("flag =>" + flag + "lens =>" + lens + "headcode =>" + headcode + "status =>" + status + "messageLen =>" + messageLen);

        if (flag == 1)
        {
            string         message  = Encoding.UTF8.GetString(buffers.ReadBytes(messageLen));
            ClientResponse response = new ClientResponse();
            response.status   = status;
            response.message  = message;
            response.headCode = headcode;
            Debug.Log("response.headCode = " + response.headCode + "  response.message =   " + message);
            SocketEventHandle.getInstance().addResponse(response);
        }
        if (buffers.BaseStream.Position < buffers.BaseStream.Length)
        {
            readBuffer(buffers);
        }
    }
Esempio n. 5
0
    private void readBuffer(BinaryReader buffers)
    {
        byte flag = buffers.ReadByte();
        int  lens = ReadInt(buffers.ReadBytes(4));

        disConnectCount = 0;
        if (!hasStartTimer && lens == 16)
        {
            startTimer();
            hasStartTimer = true;
        }
        //Debug.Log ("lengs ====>>  "+lens);

        if (lens > buffers.BaseStream.Length)
        {
            waitLen = lens;
            isWait  = true;
            buffers.BaseStream.Position = 0;
            byte[] dd   = new byte[buffers.BaseStream.Length];
            byte[] temp = buffers.ReadBytes((int)buffers.BaseStream.Length);
            Array.Copy(temp, 0, dd, 0, (int)buffers.BaseStream.Length);
            if (sources == null)
            {
                sources = dd;
            }
            return;
        }
        int   headcode   = ReadInt(buffers.ReadBytes(4));
        int   status     = ReadInt(buffers.ReadBytes(4));
        short messageLen = ReadShort(buffers.ReadBytes(2));

        if (flag == 1)
        {
            string         message  = Encoding.UTF8.GetString(buffers.ReadBytes(messageLen));
            ClientResponse response = new ClientResponse();
            response.status   = status;
            response.message  = message;
            response.headCode = headcode;
            if (headcode != APIS.HeadRESPONSE)
            {
                Debug.LogFormat("response msg, head code: {0:X}, status: {1:X}, message: {2}.", response.headCode, status, message);
            }
            SocketEventHandle.getInstance().addResponse(response);
        }
        if (buffers.BaseStream.Position < buffers.BaseStream.Length)
        {
            readBuffer(buffers);
        }
    }
Esempio n. 6
0
    public void timeout(object source, System.Timers.ElapsedEventArgs e)
    {
        //MyDebug.Log ("disConnectCount+" + disConnectCount);
        disConnectCount += 1;
        if (disConnectCount >= 3)
        {
            t.Stop();

            disConnectCount = 0;
            //	closeSocket ();
            isConnected = false;
            SocketEventHandle.getInstance().noticeDisConect();
            return;
        }
    }
Esempio n. 7
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");
    }
Esempio n. 8
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
    }
Esempio n. 9
0
    private void readBuffer(BinaryReader buffers)
    {
        byte flag = buffers.ReadByte();
        int  lens = ReadInt(buffers.ReadBytes(4));

        if (lens > buffers.BaseStream.Length)
        {
            waitLen = lens;
            isWait  = true;
            buffers.BaseStream.Position = 0;
            byte[] dd   = new byte[buffers.BaseStream.Length];
            byte[] temp = buffers.ReadBytes((int)buffers.BaseStream.Length);
            Array.Copy(temp, 0, dd, 0, (int)buffers.BaseStream.Length);
            if (sources == null)
            {
                sources = dd;
            }
            return;
        }
        int headcode = ReadInt(buffers.ReadBytes(4));
        int sendUuid = ReadInt(buffers.ReadBytes(4));
        int soundLen = ReadInt(buffers.ReadBytes(4));

        if (flag == 1)
        {
            byte[]         sound    = buffers.ReadBytes(soundLen);
            ClientResponse response = new ClientResponse();
            response.headCode = headcode;
            response.bytes    = sound;
            response.message  = sendUuid.ToString();
            MyDebug.Log("--chatSocketUrl---" + "chat.headCode = " + response.headCode + "  sound.lenght =   " + soundLen);
            MyDebug.Log("chat.headCode = " + response.headCode + "  sound.lenght =   " + soundLen);
            SocketEventHandle.getInstance().addResponse(response);
        }
        if (buffers.BaseStream.Position < buffers.BaseStream.Length)
        {
            readBuffer(buffers);
        }
    }
Esempio n. 10
0
    void Start()
    {
        //

                #if UNITY_IPHONE && !UNITY_EDITOR
        if (GlobalDataScript.getInstance().wechatOperate.shareSdk.IsClientValid(PlatformType.WechatPlatform))
        {
            youkeBtn.SetActive(false);
            loginBtn.SetActive(true);
        }
        else
        {
            youkeBtn.SetActive(true);
            loginBtn.SetActive(false);
        }
                #else
        youkeBtn.SetActive(false);
        loginBtn.SetActive(true);
                #endif


        //shareSdk.showUserHandler = getUserInforCallback;//注册获取用户信息回调
        CustomSocket.hasStartTimer = false;
        SocketEventHandle.getInstance().LoginCallBack    += LoginCallBack;
        SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse;


        GlobalDataScript.isonLoginPage = true;
        versionText.text = "版本号:" + Application.version;
        //WxPayImpl test = new WxPayImpl(gameObject);
        //test.callTest ("dddddddddddddddddddddddddddd");
        StartCoroutine(ConnectTime1(3f, 1));

        //每隔0.1秒執行一次定時器
        InvokeRepeating("isConnected", 0.1f, 0.1f);

        GlobalDataScript.headTime = GlobalDataScript.GetTimeStamp();
    }
Esempio n. 11
0
    void Start()
    {
        //shareSdk.showUserHandler = getUserInforCallback;//注册获取用户信息回调
        CustomSocket.hasStartTimer = false;
        SoundCtrl.getInstance().playBGM(1);
        SocketEventHandle.getInstance().LoginCallBack    += LoginCallBack;
        SocketEventHandle.getInstance().RoomBackResponse += RoomBackResponse;


        GlobalDataScript.isonLoginPage = true;
        versionText.text = "版本号:" + Application.version;
        //WxPayImpl test = new WxPayImpl(gameObject);
        //test.callTest ("dddddddddddddddddddddddddddd");
        if (watingPanel != null)
        {
            //watingPanel.SetActive(false);
            watingPanel.GetComponentInChildren <Text>().text = "正在连接服务器...";
        }
        StartCoroutine(ConnectTime1(1f, 1));

        //每隔0.1秒執行一次定時器
        InvokeRepeating("isConnected", 1, 0.1f);
    }
Esempio n. 12
0
    private RoomCreateVo sendVo;              //创建房间的信息
    void Start()
    {
        int x = PlayerPrefs.GetInt("userDefaultMJ");

        if (x == 0)
        {
            openZhuanzhuanSeetingPanel();
        }
        else if (x == 1)
        {
            openHuashuiSeetingPanel();
        }
        else if (x == 2)
        {
            openChangshaSeetingPanel();
        }
        else if (x == 3)
        {
            openGuangDongSeetingPanel();
        }

        SocketEventHandle.getInstance().CreateRoomCallBack += onCreateRoomCallback;
    }
Esempio n. 13
0
 /// <summary>
 /// 发送心跳包
 /// </summary>
 /// *
 public bool sendHeadData()
 {
     try {
         if (stream != null && tcpclient.Connected)
         {
             stream.Write(headBytes, 0, headBytes.Length);
             return(true);
         }
         else
         {
             isConnected = false;
             SocketEventHandle.getInstance().noticeDisConect();
             return(false);
         }
     } catch (Exception ex) {
         Debug.Log(ex.ToString());
         isConnected = false;
         showMessageTip("服务器已断开连接,请重新登录");
         isConnected = false;
         SocketEventHandle.getInstance().noticeDisConect();
         return(false);
     }
 }
Esempio n. 14
0
 public void removeListener()
 {
     SocketEventHandle.getInstance().dissoliveRoomResponse -= dissoliveRoomResponse;
 }
Esempio n. 15
0
 private void addListener()
 {
     SocketEventHandle.getInstance().dissoliveRoomResponse += dissoliveRoomResponse;
 }
Esempio n. 16
0
    private void cleaListener()
    {
        /*
         * if (SocketEventHandle.getInstance ().LoginCallBack != null) {
         *      SocketEventHandle.getInstance ().LoginCallBack = null;
         * }
         */
        if (SocketEventHandle.getInstance().CreateRoomCallBack != null)
        {
            SocketEventHandle.getInstance().CreateRoomCallBack = null;
        }

        if (SocketEventHandle.getInstance().JoinRoomCallBack != null)
        {
            SocketEventHandle.getInstance().JoinRoomCallBack = null;
        }

        if (SocketEventHandle.getInstance().StartGameNotice != null)
        {
            SocketEventHandle.getInstance().StartGameNotice = null;
        }

        if (SocketEventHandle.getInstance().pickCardCallBack != null)
        {
            SocketEventHandle.getInstance().pickCardCallBack = null;
        }

        if (SocketEventHandle.getInstance().otherPickCardCallBack != null)
        {
            SocketEventHandle.getInstance().otherPickCardCallBack = null;
        }

        if (SocketEventHandle.getInstance().putOutCardCallBack != null)
        {
            SocketEventHandle.getInstance().putOutCardCallBack = null;
        }

        if (SocketEventHandle.getInstance().PengCardCallBack != null)
        {
            SocketEventHandle.getInstance().PengCardCallBack = null;
        }

        if (SocketEventHandle.getInstance().GangCardCallBack != null)
        {
            SocketEventHandle.getInstance().GangCardCallBack = null;
        }

        if (SocketEventHandle.getInstance().HupaiCallBack != null)
        {
            SocketEventHandle.getInstance().HupaiCallBack = null;
        }


        if (SocketEventHandle.getInstance().gangCardNotice != null)
        {
            SocketEventHandle.getInstance().gangCardNotice = null;
        }



        if (SocketEventHandle.getInstance().btnActionShow != null)
        {
            SocketEventHandle.getInstance().btnActionShow = null;
        }

        if (SocketEventHandle.getInstance().outRoomCallback != null)
        {
            SocketEventHandle.getInstance().outRoomCallback = null;
        }

        if (SocketEventHandle.getInstance().dissoliveRoomResponse != null)
        {
            SocketEventHandle.getInstance().dissoliveRoomResponse = null;
        }

        if (SocketEventHandle.getInstance().gameReadyNotice != null)
        {
            SocketEventHandle.getInstance().gameReadyNotice = null;
        }



        if (SocketEventHandle.getInstance().messageBoxNotice != null)
        {
            SocketEventHandle.getInstance().messageBoxNotice = null;
        }



        if (SocketEventHandle.getInstance().backLoginNotice != null)
        {
            SocketEventHandle.getInstance().backLoginNotice = null;
        }

        /*
         * if (SocketEventHandle.getInstance ().RoomBackResponse != null) {
         *      SocketEventHandle.getInstance ().RoomBackResponse = null;
         * }
         */

        if (SocketEventHandle.getInstance().cardChangeNotice != null)
        {
            SocketEventHandle.getInstance().cardChangeNotice = null;
        }



        if (SocketEventHandle.getInstance().offlineNotice != null)
        {
            SocketEventHandle.getInstance().offlineNotice = null;
        }

        if (SocketEventHandle.getInstance().onlineNotice != null)
        {
            SocketEventHandle.getInstance().onlineNotice = null;
        }

        if (SocketEventHandle.getInstance().giftResponse != null)
        {
            SocketEventHandle.getInstance().giftResponse = null;
        }

        if (SocketEventHandle.getInstance().returnGameResponse != null)
        {
            SocketEventHandle.getInstance().returnGameResponse = null;
        }

        if (SocketEventHandle.getInstance().gameFollowBanderNotice != null)
        {
            SocketEventHandle.getInstance().gameFollowBanderNotice = null;
        }

        if (SocketEventHandle.getInstance().contactInfoResponse != null)
        {
            SocketEventHandle.getInstance().contactInfoResponse = null;
        }

        if (SocketEventHandle.getInstance().zhanjiResponse != null)
        {
            SocketEventHandle.getInstance().zhanjiResponse = null;
        }



        if (SocketEventHandle.getInstance().zhanjiDetailResponse != null)
        {
            SocketEventHandle.getInstance().zhanjiDetailResponse = null;
        }

        if (SocketEventHandle.getInstance().gameBackPlayResponse != null)
        {
            SocketEventHandle.getInstance().gameBackPlayResponse = null;
        }
    }
Esempio n. 17
0
 void Awake()
 {
     SocketEventHandle.getInstance().disConnetNotice        += disConnetNotice;
     SocketEventHandle.getInstance().hostUpdateDrawResponse += hostUpdateDrawResponse;
     SocketEventHandle.getInstance().otherTeleLogin         += otherTeleLogin;
 }
 private void removeListener()
 {
     SocketEventHandle.getInstance().JoinRoomCallBack -= onJoinRoomCallBack;
 }
Esempio n. 19
0
 void Awake()
 {
     SocketEventHandle.getInstance().disConnetNotice += disConnetNotice;
     SocketEventHandle.getInstance().otherTeleLogin  += otherTeleLogin;
 }
Esempio n. 20
0
 private void removeListener()
 {
     instance = null;
     SocketEventHandle.getInstance().startPayOrderResponse -= startPayOrderCallback;
     SocketEventHandle.getInstance().paySuccessResponse    -= paySuccessCallback;
 }
Esempio n. 21
0
 private void  removeListener()
 {
     SocketEventHandle.getInstance().zhanjiResponse       -= zhanjiResponse;
     SocketEventHandle.getInstance().zhanjiDetailResponse -= zhanjiDetailResponse;
 }
Esempio n. 22
0
 public void serviceErrorNotice(ClientResponse response)
 {
     SocketEventHandle.getInstance().serviceErrorNotice -= serviceErrorNotice;
     TipsManagerScript.getInstance().setTips(response.message);
 }
Esempio n. 23
0
 public void exitSure_Click()
 {
     SocketEventHandle.getInstance().gameBackPlayResponse -= gameBackPlayResponse;
     Destroy(this);
     Destroy(gameObject);
 }
Esempio n. 24
0
 public void addListener()
 {
     SocketEventHandle.getInstance().FinalGameOverCallBack += finalGameOverCallBack;
 }
Esempio n. 25
0
 private void addListener()
 {
     SocketEventHandle.getInstance().gameBackPlayResponse += gameBackPlayResponse;
 }
Esempio n. 26
0
 public void removeListener()
 {
     SocketEventHandle.getInstance().FinalGameOverCallBack -= finalGameOverCallBack;
 }
Esempio n. 27
0
 public ServiceErrorListener()
 {
     SocketEventHandle.getInstance().serviceErrorNotice += serviceErrorNotice;
 }
    void Start()
    {
        SocketEventHandle.getInstance().CreateRoomCallBack += onCreateRoomCallback;

        initToggle();
    }
Esempio n. 29
0
 private void removeListener()
 {
     SocketEventHandle.getInstance().LoginCallBack    -= LoginCallBack;
     SocketEventHandle.getInstance().RoomBackResponse -= RoomBackResponse;
 }
Esempio n. 30
0
 /***
  * 关闭对话框
  */
 public void closeDialog()
 {
     SocketEventHandle.getInstance().giftResponse -= giftResponse;
     Destroy(this);
     Destroy(gameObject);
 }