Exemplo n.º 1
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            if (AppValues.UserInfoBuilder == null)
            {
                this.Text = "测试服务器框架工具 by 张齐 (未登录)";
            }
            else
            {
                this.Text = string.Format("测试服务器框架工具 by 张齐 (已登录用户:{0})", AppValues.UserInfoBuilder.Username);
            }

            RefreshUiForUserState();
            // 如果已经处于对战中,就要获取当前战场信息
            if (AppValues.UserInfoBuilder.UserState.ActionState == UserActionStateEnum.Playing)
            {
                GetBattleInfoRequest.Builder builder = GetBattleInfoRequest.CreateBuilder();
                WebSocketManager.SendMessage(RpcNameEnum.GetBattleInfo, builder.Build().ToByteArray(), OnGetBattleInfoCallback);
            }
        }
Exemplo n.º 2
0
        private void DelegateOnMatchResultPushCallback(Object obj)
        {
            ResponseMsg     msg             = obj as ResponseMsg;
            MatchResultPush matchResultPush = MatchResultPush.ParseFrom(msg.ProtoData);

            if (matchResultPush.IsSuccess == false)
            {
                MessageBox.Show(this, "匹配失败", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                UserState.Builder userStateBuilder = AppValues.UserInfoBuilder.UserState.ToBuilder();
                userStateBuilder.SetActionState(UserActionStateEnum.Playing);
                userStateBuilder.SetBattleType(matchResultPush.BattleType);
                userStateBuilder.SetBattleId(matchResultPush.BattleId);
                AppValues.UserInfoBuilder.SetUserState(userStateBuilder);

                RefreshUiForUserState();

                // 请求获取战场信息
                GetBattleInfoRequest.Builder builder = GetBattleInfoRequest.CreateBuilder();
                WebSocketManager.SendMessage(RpcNameEnum.GetBattleInfo, builder.Build().ToByteArray(), OnGetBattleInfoCallback);
            }
        }