public void Send(int opCode, int subCode, object value)
    {
        SocketMsg msg = new SocketMsg(opCode, subCode, value);

        Send(msg);
    }
Exemple #2
0
 /// <summary>
 /// 收到数据时的处理
 /// </summary>
 /// <param name="msg"></param>
 public abstract void OnReceive(SocketMsg msg);
Exemple #3
0
    public void SendMessage(int OpCode, int SubCode, object Value)
    {
        SocketMsg msg = new SocketMsg(OpCode, SubCode, Value);

        SendMessage(msg);
    }
Exemple #4
0
    /// <summary>
    /// 账号模块
    /// </summary>
    /// <param name="msg"></param>
    private void accountSocketMsg(SocketMsg msg)
    {
        switch (msg.data.type)
        {
        case "logoin":
            if (accountHandler.OnReceive(EventType.login, msg.data.t["desc"]))
            {
                if (msg.data.t.ContainsKey("token"))
                {
                    PlayerPrefs.SetString("token", msg.data.t["token"]);
                }

                _wabData.ThreadStart();
            }
            break;

        case "reg":
            accountHandler.OnReceive(EventType.regist, msg.data.t["desc"]);
            break;

        case "voice":
            // setHandler.OnReceive(EventType.voiceset, msg.data.t);
            break;

        case "expw":
            setHandler.OnReceive(EventType.expw, msg.data.t["desc"]);
            break;

        case "expwshop":
            setHandler.OnReceive(EventType.expw, msg.data.t["desc"]);
            break;

        case "addfriend":
            friendHandler.OnReceive(EventType.addfriend, msg.data.t["desc"]);
            break;

        case "likefriend":
            // friendHandler.OnReceive(EventType.likefriend, msg.data.t["desc"]);
            break;

        case "seachfriend":
            friendHandler.OnReceive(EventType.searchfriend, msg.data.t);
            break;

        case "squarefriend":
            friendHandler.OnReceive(EventType.squarefriend, msg.data.t);
            break;

        case "applyfriend":

            friendHandler.OnReceive(EventType.applyfriend, msg.data.t);
            break;

        case "pwforget":
            //setHandler.OnReceive(EventType)
            break;

        default:
            break;
        }
    }
Exemple #5
0
    public override void Execute(int eventCode, object message)
    {
        //初始化操作
        if (eventCode == EventType.init && _wabData.WebSocket == null)
        {
            _wabData.OpenWebSocket();
            if (PlayerPrefs.HasKey("token"))
            {
                Dictionary <string, string> logMsg = new Dictionary <string, string>()
                {
                    ["token"] = PlayerPrefs.GetString("token"),
                };
                _wabData.SendMsg(logMsg);
            }
        }

        if (_wabData.WebSocket != null && _wabData.WebSocket.IsAlive) //调试TODO(true)
        {
            switch (eventCode)
            {
            case EventType.pwlogin:
                //密码登入操作
                socketMsg = accountRequestMsg.ReqPWLoginMsg(message);
                if (socketMsg == null)
                {
                    return;
                }
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.idlogin:
                //验证码登入
                socketMsg = accountRequestMsg.ReqIDLoginMsg(message);
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.regist:
                //注册操作
                socketMsg = accountRequestMsg.ReqRegMsg(message);
                if (socketMsg == null)
                {
                    return;
                }
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.pwforget:
                //忘记密码
                socketMsg = accountRequestMsg.ReqPWChangeMsg(message);
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.addfriend:
                //添加好友
                socketMsg = friendRequestMsg.ReqAddFriendMsg(message);
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.identy:
                //获取验证码
                socketMsg = accountRequestMsg.ReqGetIdentityMsg(message);
                if (socketMsg == null)
                {
                    return;
                }
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.expw:
                //修改密码TODO 暂时设置和忘记密码模块一样
                socketMsg = accountRequestMsg.ReqPWChangeMsg(message);
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.expwshop:
                //设置交易密码
                socketMsg = setRequestMsg.ReqExPwShopMsg(message);
                _wabData.SendMsg(socketMsg);
                break;

            //case EventType.voiceset:
            //    //音效设置
            //    socketMsg = setRequestMsg.ReqVoiceSetMsg(message);
            //    _wabData.SendMsg(socketMsg);
            //    break;
            case EventType.searchfriend:
                //搜索用户
                socketMsg = friendRequestMsg.ReqSearchUserMsg(message);
                if (socketMsg == null)
                {
                    return;
                }
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.likefriend:
                //好友点赞
                socketMsg = friendRequestMsg.ReqLikeFriendMsg(message);
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.applytofriend:
                //申请通过/拒绝
                socketMsg = friendRequestMsg.ReqAgreeFriendMsg(message);
                _wabData.SendMsg(socketMsg);
                break;

            case EventType.exit:
                socketMsg      = new SocketMsg();
                socketMsg.desc = "exit";
                socketMsg.data = null;
                _wabData.SendMsg(socketMsg);
                _wabData.WebSocket.Close(1000, "Bye!");
                break;

            default:
                break;
            }
        }
        else
        {
            Debug.LogError("连接断开");
        }
    }
Exemple #6
0
 private void Awake()
 {
     //Bind(UIEvent.START_PANEL_EVENTCODE);
     account = new AccountDto();
     msg     = new SocketMsg();
 }
Exemple #7
0
 private void Awake()
 {
     account = new AccountDto();
     msg     = new SocketMsg();
 }
 public void Send(SocketMsg msg)
 {
     Send(msg.OpCode, msg.SubCode, msg.Value);
 }
Exemple #9
0
 /// <summary>消息分发</summary>
 public void HandOutMsg(SocketMsg msg)
 {
     NetcomManager.Instance.ReceiveMsg((GameMsg)msg);
 }
Exemple #10
0
 public MsgPackage(SessionTcp session, SocketMsg msg)
 {
     this.session = session;
     this.msg     = msg;
 }
Exemple #11
0
 /// <summary>
 /// 发送数据
 /// </summary>
 /// <param name="msg">消息</param>
 public void Send(SocketMsg msg)
 {
     client.Send(msg);
 }
Exemple #12
0
    protected virtual void Start()
    {
        thisWager = 10;

        btnStart = transform.Find("btnStart").GetComponent <Button>();
        btnNext  = transform.Find("btnNext").GetComponent <Button>();
        btnLeave = transform.Find("btnLeave").GetComponent <Button>();
        btnGet   = transform.Find("btnGet").GetComponent <Button>();
        btnNGet  = transform.Find("btnNGet").GetComponent <Button>();

        btnDoWager   = transform.Find("btnDoWager").GetComponent <Button>();
        btnReWager   = transform.Find("btnReWager").GetComponent <Button>();
        btnDouble    = transform.Find("btnDouble").GetComponent <Button>();
        btnSplit     = transform.Find("btnSplit").GetComponent <Button>();
        btnNextSplit = transform.Find("btnNextSplit").GetComponent <Button>();

        btn10   = transform.Find("btn10").GetComponent <Button>();
        btn100  = transform.Find("btn100").GetComponent <Button>();
        btn1000 = transform.Find("btn1000").GetComponent <Button>();

        btnCount    = transform.Find("btnCount").GetComponent <Button>();
        btnStrategy = transform.Find("btnStrategy").GetComponent <Button>();


        btnStart.onClick.AddListener(startClick);
        btnNext.onClick.AddListener(nextClick);
        btnGet.onClick.AddListener(getClick);
        btnLeave.onClick.AddListener(leaveClick);
        btnNGet.onClick.AddListener(ngetClick);

        btnDoWager.onClick.AddListener(changeWagerClick);
        btnReWager.onClick.AddListener(changeWagerClick);

        btn10.onClick.AddListener(btn10Click);
        btn100.onClick.AddListener(btn100Click);
        btn1000.onClick.AddListener(btn1000Click);

        btnDouble.onClick.AddListener(btnDoubleClick);
        btnSplit.onClick.AddListener(btnSplitClick);
        btnNextSplit.onClick.AddListener(btnNextSplitClick);

        btnCount.onClick.AddListener(btnCountClick);
        btnStrategy.onClick.AddListener(btnStrategyClick);

        socketMsg = new SocketMsg();


        //默认状态
        btnNext.gameObject.SetActive(false);
        btnLeave.gameObject.SetActive(false);
        btnGet.gameObject.SetActive(false);
        btnNGet.gameObject.SetActive(false);

        btnReWager.gameObject.SetActive(false);
        btnDouble.gameObject.SetActive(false);
        btnSplit.gameObject.SetActive(false);
        btnNextSplit.gameObject.SetActive(false);
        btn10.gameObject.SetActive(false);
        btn100.gameObject.SetActive(false);
        btn1000.gameObject.SetActive(false);
        //fixbug923
        //UserDto myUserDto = Models.GameModel.MatchRoomDto.UIdUserDict[Models.GameModel.UserDto.Id];
        //this.userDto = myUserDto;
    }