Example #1
0
    private void clickNumber(string number)
    {
        MyDebug.Log(number.ToString());
        if (inputChars.Count >= 6)
        {
            return;
        }
        inputChars.Add(number);

        int index = inputChars.Count;

        inputsWithText [index - 1].text = number.ToString();
        //inputTexts[index - 1].enabled = true;
        //inputTexts[index - 1].sprite = numberList[int.Parse(number)];
        //inputTexts[index - 1].SetNativeSize();


        if (inputChars.Count == 6)
        {
            String roomNumber = inputChars[0] + inputChars[1] + inputChars[2] + inputChars[3] + inputChars[4] + inputChars[5];
            MyDebug.Log(roomNumber);
            RoomJoinVo roomJoinVo = new RoomJoinVo();
            roomJoinVo.roomId = int.Parse(roomNumber);
            string sendMsg = JsonMapper.ToJson(roomJoinVo);
            CustomSocket.getInstance().sendMsg(new JoinRoomRequest(sendMsg));
        }
    }
Example #2
0
    /// <summary>
    /// 登录
    /// </summary>
    public void Login()
    {
        CustomSocket.getInstance().sendMsg(new LoginRequest(null));

        //if(username=="123"&&password=="123"){
        // //执行登录操作
        //    Debug.Log("登录中...............");
        //    CustomSocket.getInstance().sendMsg(new LoginRequest(null));
        //}
        //else if(username=="1234"&&password=="1234"){
        //    Debug.Log("2........登录中...............");
        //    CustomSocket.getInstance().sendMsg(new LoginRequest(null));
        //}
        //else if (username == "12345" && password == "12345")
        //{
        //    Debug.Log("2........登录中...............");
        //    CustomSocket.getInstance().sendMsg(new LoginRequest(username));
        //}
        //else if (username == "123456" && password == "123456")
        //{
        //    Debug.Log("2........登录中...............");
        //    CustomSocket.getInstance().sendMsg(new LoginRequest(username));
        //}
        //else if (username == "1234567" && password == "1234567")
        //{
        //    Debug.Log("2........登录中...............");
        //    CustomSocket.getInstance().sendMsg(new LoginRequest(username));
        //}
    }
Example #3
0
    IEnumerator retry()
    {
        yield return(new WaitForSeconds(10.0f));

        CustomSocket.getInstance().sendMsg(new PaySuccessRequest(checkingOrder));
        retryTimes++;
    }
Example #4
0
        public void  openGamePlay()
        {
            string id = mZhanjiDataItemVo.id + "";

            CustomSocket.getInstance().sendMsg(new GameBackPlayRequest(id));
            PrefabManage.loadPerfab("Prefab/Panel_GamePlayBack");
        }
 void Start()
 {
     SocketEventHandle.getInstance().giftResponse += giftResponse;
     CommonEvent.getInstance().prizeCountChange   += prizeCountChange;
     CustomSocket.getInstance().sendMsg(new GetGiftRequest("0"));
     choujiangNum.text = GlobalDataScript.loginResponseData.account.prizecount + "";
 }
Example #6
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)
            {
            }
        }
    }
Example #7
0
        private static async void StartAsyncClient(string host, int id)
        {
            var ipHostInfo     = Dns.GetHostEntry(host.Split('/')[0]);
            var ipAddress      = ipHostInfo.AddressList[0];
            var remoteEndpoint = new IPEndPoint(ipAddress, Parser.PORT);

            // create the TCP/IP socket
            var client = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); // create client socket

            var requestSocket = new CustomSocket
            {
                sock           = client,
                hostname       = host.Split('/')[0],
                endpoint       = host.Contains("/") ? host.Substring(host.IndexOf("/", StringComparison.Ordinal)) : "/",
                remoteEndPoint = remoteEndpoint,
                id             = id
            };                                 // state object

            await ConnectAsync(requestSocket); // connect to remote server

            await SendAsync(requestSocket,
                            Parser.GetRequestString(requestSocket.hostname, requestSocket.endpoint)); // request data from the server

            await ReceiveAsync(requestSocket);                                                        // receive server response

            Console.WriteLine("Connection {0} > Content length is:{1}", requestSocket.id, Parser.GetContentLen(requestSocket.responseContent.ToString()));

            // release the socket
            client.Shutdown(SocketShutdown.Both);
            client.Close();
        }
Example #8
0
    public void exit()
    {
        CustomSocket.getInstance().sendMsg(new LoginRequest());

        Application.Quit();
        //多态  调用退出登录接口
    }
Example #9
0
        private static Task Receive(CustomSocket state)
        {
            // receive data
            state.sock.BeginReceive(state.buffer, 0, CustomSocket.BUFF_SIZE, 0, ReceiveCallback, state);

            return(Task.FromResult(state.receiveDone.WaitOne()));
        }
Example #10
0
    public void login()
    {
        MyDebug.Log("----------------1-------------------");
        if (!CustomSocket.getInstance().isConnected)
        {
            StartCoroutine(ConnectTime1(3f, 1));
            InvokeRepeating("isConnected", 0.1f, 0.1f);

            tapCount = 0;
            MyDebug.Log("----------------2------------------");
            return;
        }

        GlobalDataScript.reinitData();         //初始化界面数据
        if (agreeProtocol.isOn)
        {
            MyDebug.Log("----------------3------------------");
            doLogin();
            watingPanel.GetComponentInChildren <Text> ().text = "进入游戏中";
            watingPanel.SetActive(true);

            StartCoroutine(ConnectTime(5f, 1));
        }
        else
        {
            MyDebug.Log("请先同意用户使用协议");
            TipsManagerScript.getInstance().setTips("请先同意用户使用协议");
        }

        tapCount += 1;
        Invoke("resetClickNum", 10f);
    }
Example #11
0
    public void sureRoomNumber()
    {
        if (inputChars.Count != 6)
        {
            MyDebug.Log("请先完整输入房间号码!");

            TipsManagerScript.getInstance().setTips("请先完整输入房间号码!");
            return;
        }

        if (watingPanel != null)
        {
            watingPanel.gameObject.SetActive(true);
        }


        String roomNumber = inputChars[0] + inputChars[1] + inputChars[2] + inputChars[3] + inputChars[4] + inputChars[5];

        MyDebug.Log(roomNumber + "此处加入房间输入房间号,并发送到服务器判断是否有此房间存在");
        RoomJoinVo roomJoinVo = new RoomJoinVo();

        roomJoinVo.roomId = int.Parse(roomNumber);
        string sendMsg = JsonMapper.ToJson(roomJoinVo);

        StartCoroutine(ConnectTime(4f, 1));
        CustomSocket sok = CustomSocket.getInstance();

        sok.sendMsg(new JoinRoomRequest(sendMsg));

        if (SocketEventHandle.getInstance().serviceErrorNotice != null)
        {
            SocketEventHandle.getInstance().serviceErrorNotice = null;
        }
        SocketEventHandle.getInstance().serviceErrorNotice += serviceErrorNotice;
    }
Example #12
0
    public void reStratGame()
    {
        if (GlobalDataScript.isOverByPlayer)
        {
            //TipsManagerScript.getInstance ().setTips ("房间已解散,不能重新开始游戏");
            closeDialog();
            return;
        }

        if (GlobalDataScript.surplusTimes > 0)
        {
            if (GlobalDataScript.roomVo.gameType == 0)
            {
                CustomSocket.getInstance().sendMsg(new GameReadyRequest());
                CommonEvent.getInstance().readyGame();
            }
            closeDialog();
        }
        else
        {
            //TipsManagerScript.getInstance ().setTips ("游戏局数已经用完,无法重新开始游戏");
            closeDialog();
        }
        SoundCtrl.getInstance().playSoundByActionButton(1);
    }
    /**
     * 创建划水麻将房间
     */
    public void createHuashuiRoom()
    {
        int  roundNumber = 4;     //房卡数量
        bool isZimo      = false; //自摸
        bool isFengpai   = false; //七小对
        int  maCount     = 0;

        for (int i = 0; i < huashuiRoomCards.Count; i++)
        {
            Toggle item = huashuiRoomCards [i];
            if (item.isOn)
            {
                if (i == 0)
                {
                    roundNumber = 8;
                }
                else if (i == 1)
                {
                    roundNumber = 16;
                }
                break;
            }
        }
        if (huashuiGameRule [0].isOn)
        {
            isFengpai = true;
        }
        if (huashuiGameRule [1].isOn)
        {
            isZimo = true;
        }


        for (int i = 0; i < huashuixiayu.Count; i++)
        {
            if (huashuixiayu [i].isOn)
            {
                maCount = 2 * (i + 1);
                break;
            }
        }

        sendVo             = new RoomCreateVo();
        sendVo.xiaYu       = maCount;
        sendVo.roundNumber = roundNumber;
        sendVo.ziMo        = isZimo?1:0;
        sendVo.roomType    = GameConfig.GAME_TYPE_HUASHUI;
        sendVo.addWordCard = isFengpai;
        sendVo.sevenDouble = true;
        string sendmsgstr = JsonMapper.ToJson(sendVo);

        if (GlobalDataScript.loginResponseData.account.roomcard > 0)
        {
            CustomSocket.getInstance().sendMsg(new CreateRoomRequest(sendmsgstr));
        }
        else
        {
            TipsManagerScript.getInstance().setTips("你的房卡数量不足,不能创建房间");
        }
    }
Example #14
0
    public void youkeLogin()
    {
        watingPanel.GetComponentInChildren <Text> ().text = "进入游戏中";
        watingPanel.SetActive(true);

        CustomSocket.getInstance().sendMsg(new LoginRequest(null));
    }
Example #15
0
        void FixedUpdate()
        {
            while (callBackResponseList.Count > 0)
            {
                ClientResponse response = callBackResponseList [0];
                callBackResponseList.RemoveAt(0);
                dispatchHandle(response);
            }

            //每隔一秒检测是否掉线
            timeAll += Time.deltaTime;
            if (timeAll > 1)
            {
                timeAll = 0;
                CustomSocket.getInstance().sendHeadData02();
            }


            if (isDisconnet)
            {
                isDisconnet = false;
                if (disConnetNotice != null)
                {
                    disConnetNotice();
                }
            }
        }
    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);
    }
Example #17
0
    private void ReqForCreateRoom(string msg)
    {
        int gold = 10;

        if (GlobalDataScript.userGameType == GameType.GameType_PK_DN)
        {
            gold = 5;
        }
        if (GlobalDataScript.goldType)
        {
            if (GlobalDataScript.loginResponseData.account.gold >= gold)
            {
                watingPanel.gameObject.SetActive(true);
                CustomSocket.getInstance().sendMsg(new CreateRoomRequest(msg));
                userDefaultSet = msg;
            }
            else
            {
                TipsManagerScript.getInstance().setTips("你的金币不足,不能匹配到训练场");
            }
        }
        else
        {
            if (GlobalDataScript.loginResponseData.account.roomcard > 0)
            {
                watingPanel.gameObject.SetActive(true);
                CustomSocket.getInstance().sendMsg(new CreateRoomRequest(msg));
                userDefaultSet = msg;
            }
            else
            {
                TipsManagerScript.getInstance().setTips("你的房卡数量不足,不能创建房间");
            }
        }
    }
Example #18
0
        private static async Task ReceiveAsync(CustomSocket state)
        {
            // receive data
            state.sock.BeginReceive(state.buffer, 0, CustomSocket.BUFF_SIZE, 0, ReceiveCallback, state);

            await Task.FromResult <object>(state.receiveDone.WaitOne());
        }
Example #19
0
    public void OnGetApplyClubCallBack(ClientResponse response)
    {
        ClubAccountVO vo = JsonMapper.ToObject <ClubAccountVO>(response.message);

        if (vo.msgcode != 0)
        {
            TipsManagerScript.getInstance().setTips(vo.msgstring);
        }
        else
        {
            isagreePanelShow = true;
            agreeListPanel.SetActive(true);
            PrefabUtils.ClearChild(agreeListGrid);
            foreach (ClubAccount ac in vo.listaccount)
            {
                GameObject     child = PrefabUtils.AddChild(agreeListGrid, agreesub);
                agreeSubScript cs    = child.GetComponent <agreeSubScript>();
                cs.setValue(ac);
                cs.agreebtn.onClick.AddListener(() =>
                {
                    ClientRequest cr  = new ClientRequest();
                    cr.headCode       = APIS.AGREE_CLUB_REQUEST;
                    cr.messageContent = "{'agree':1,'uuid':" + ac.uuid + "}";
                    CustomSocket.getInstance().sendMsg(cr);
                });
                cs.nobtn.onClick.AddListener(() =>
                {
                    ClientRequest cr  = new ClientRequest();
                    cr.headCode       = APIS.AGREE_CLUB_REQUEST;
                    cr.messageContent = "{'agree':0,'uuid':" + ac.uuid + "}";
                    CustomSocket.getInstance().sendMsg(cr);
                });
            }
        }
    }
        public double SugenoProcessing(FactSet factSet)
        {
            var type       = typeof(CustomSocket);
            var socket     = new CustomSocket();
            var fuzzyFacts = new List <FuzzyFact>();

            foreach (var fact in factSet.Facts)
            {
                type.GetProperty(fact.Domain.ToString()).SetValue(socket, fact.Value);
                fuzzyFacts.Add(FactFuzzification(fact));
            }

            DebugWrite($"Приведение к нечеткости входных фактов:\n" + string.Join("\n", fuzzyFacts));

            var statements = _generator.GetFuzzyFuncStatements(_domains);

            var degreeResults = new List <FuzzyFuncProcessed>();

            foreach (var statement in statements)
            {
                var degree = statement.SetRulesFacts(fuzzyFacts).GetRulesDegree();
                var result = statement.Result(socket);
                degreeResults.Add(new FuzzyFuncProcessed {
                    Degree = degree, Result = result
                });
            }

            DebugWrite($"Нечеткие правила:\n" + string.Join("\n", statements));

            var numerator   = degreeResults.Aggregate(0d, (acc, p) => acc + p.Degree * p.Result);
            var denumerator = degreeResults.Aggregate(0d, (acc, p) => acc + p.Degree);

            return(numerator / denumerator);
        }
Example #21
0
    public List <Toggle> beishu;     // 1.  5倍   2.   10倍    3. 20倍

    public void createXiazui()
    {
        gameObject.SetActive(false);
        int XZList   = 0; // 下嘴的组合  147  258  369
        int XZbeishu = 0; // 下嘴的倍数  5  10   20

        for (int i = 0; i < xiazuiList.Count; i++)
        {
            Toggle item = xiazuiList[i];
            if (item.isOn)
            {
                if (i == 0)
                {
                    XZList = 1;   // 表示 147 组合
                }
                if (i == 1)
                {
                    XZList = 2;   // 表示 258 组合
                }
                if (i == 2)
                {
                    XZList = 3;    // 表示 369组合
                }
                break;
            }
        }

        for (int i = 0; i < beishu.Count; i++)
        {
            Toggle bs = beishu[i];
            if (bs.isOn)
            {
                if (i == 0)
                {
                    XZbeishu = 5;  // 5倍
                }
                if (i == 1)
                {
                    XZbeishu = 10;   // 10倍
                }
                if (i == 2)
                {
                    XZbeishu = 20;    // 20倍
                }
            }
        }

        ReadyVO readyVO = new ReadyVO();

        readyVO.phase = 1;
        XiazuiVO xiazuiVO = new XiazuiVO();

        xiazuiVO.xiazuiList     = XZList;
        xiazuiVO.xiazuiMultiple = XZbeishu;
        string sendmsg = JsonMapper.ToJson(xiazuiVO);

        CustomSocket.getInstance().sendMsg(new GameReadyRequest(readyVO));
        CustomSocket.getInstance().sendMsg(new XiazuiRequest(xiazuiVO));
    }
Example #22
0
    public void exit()
    {
        SoundCtrl.getInstance().playSoundUI();
        CustomSocket.getInstance().sendMsg(new LoginRequest());

        Application.Quit();
        //多态  调用退出登录接口
    }
Example #23
0
        public void init()
        {
            _socket     = new CustomSocket(onSocketData, onSocketStatus);
            _chatSocket = new ChatSocket(onSocketData, null);
            _cache      = new List <ClientResponse> ();

            heartbeatThread();             //开一个线程维持与服务的心跳
        }
Example #24
0
    //微信支付回调
    public void onWillPay(string str)
    {
        string[] sArray   = str.Split(',');
        string   order    = sArray [0];
        string   ticketId = sArray [1];

        CustomSocket.getInstance().sendMsg(new SaveTicketRequest(order, ticketId));
    }
 public static CustomSocket getInstance()
 {
     if (_instance == null)
     {
         _instance = new CustomSocket();
     }
     return(_instance);
 }
Example #26
0
    /**
     *  public void closeUserInfoPanel (){
     *          userInfoPanel.SetActive (false);
     *  }
     */
    public void showRoomCardPanel()
    {
        SoundCtrl.getInstance().playSoundByActionButton(1);



        CustomSocket.getInstance().sendMsg(new GetContactInfoRequest());
    }
Example #27
0
    public void reshOnClick()
    {
        ClientRequest cr = new ClientRequest();

        cr.headCode       = APIS.CLUBSTATE_REQUEST;
        cr.messageContent = "";
        CustomSocket.getInstance().sendMsg(cr);
    }
Example #28
0
    private void quitClub()
    {
        ClientRequest cr = new ClientRequest();

        cr.headCode       = APIS.QUIT_CLUB_REQUEST;
        cr.messageContent = "";
        CustomSocket.getInstance().sendMsg(cr);
    }
Example #29
0
 public void sendMsg()
 {
     if (msg.text.Length == 0)
     {
         return;
     }
     SoundCtrl.getInstance().playSoundByActionButton(1);
     CustomSocket.getInstance().sendMsg(new MessageBoxRequest(2, msg.text, GlobalDataScript.loginResponseData.account.uuid));
     if (GlobalDataScript.roomVo.gameType == 0)
     {
         if (myMaj == null)
         {
             myMaj = GameObject.Find("Panel_GamePlay(Clone)").GetComponent <MyMahjongScript> ();
         }
         if (myMaj != null)
         {
             myMaj.playerItems [0].showChatMessage(msg.text);
         }
     }
     else if (GlobalDataScript.roomVo.gameType == 1)
     {
         if (myPdk == null)
         {
             myPdk = GameObject.Find("Panel_GamePDK(Clone)").GetComponent <MyPDKScript> ();
         }
         if (myPdk != null)
         {
             myPdk.playerItems [0].showChatMessage(msg.text);
         }
     }
     else if (GlobalDataScript.roomVo.gameType == 3)
     {
         if (myDN == null && GlobalDataScript.roomVo.playerAmounts == 10)
         {
             myDN = GameObject.Find("Panel_GameDN(Clone)").GetComponent <MyDNScript> ();
         }
         if (myDN == null && GlobalDataScript.roomVo.playerAmounts == 6)
         {
             myDN = GameObject.Find("Panel_GameDN_6(Clone)").GetComponent <MyDNScript>();
         }
         if (myDN != null)
         {
             myDN.playerItems [0].showChatMessage(msg.text);
         }
     }
     else if (GlobalDataScript.roomVo.gameType == 4)
     {
         if (myDzpk == null)
         {
             myDzpk = GameObject.Find("Panel_GameDZPK(Clone)").GetComponent <MyDZPKScript> ();
         }
         if (myDzpk != null)
         {
             myDzpk.playerItems [0].showChatMessage(msg.text);
         }
     }
     hidePanel();
 }
Example #30
0
 // Use this for initialization
 void Start()
 {
     CustomSocket.hasStartTimer = false;
     // 开始连接服务端
     CustomSocket.getInstance().Connect();
     versionText.text = "版本号:" + Application.version;
     GlobalDataScript.isonLoginPage = true;
     SocketEventHandle.getInstance().LoginCallBack += LoginCallBack;
 }