Пример #1
0
        /// <summary>
        /// 회원가입 양식을 가지고 계정을 만듭니다.
        /// </summary>
        /// <param name="data">회원가입 양식을 의미합니다.</param>
        /// <returns>성공 여부를 나타냅니다.</returns>
        public bool MakeAccount(JoinData data)
        {
            string query =
                String.Format("insert into account_data( user_id, user_email, user_password, user_gender, user_nickname, last_login_date ) values ('{0}','{1}','{2}',{3},'{4}','{5}')",
                              data.user_id, data.user_email, data.user_password, data.user_gender, data.nickname, DateTime.Now.ToString(dateFormat));
            int x = 0;

            try
            {
                using (SQLiteCommand cmd = new SQLiteCommand(query, accountDB))
                {
                    x = cmd.ExecuteNonQuery();
                }
            } catch (Exception e)
            {
                Console.WriteLine("MakeAccount: " + e.Message);
                return(false);
            }

            if (x > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public void TestJoinTenthPlayer()
        {
            game.AddPlayer("Player One");
            game.AddPlayer("Player Two");
            game.AddPlayer("Player Three");
            game.AddPlayer("Player Four");
            game.AddPlayer("Player Five");
            game.AddPlayer("Player Six");
            game.AddPlayer("Player Seven");
            game.AddPlayer("Player Eight");
            game.AddPlayer("Player Nine");

            JoinData joinData = new JoinData {
                name = "My name"
            };
            var result = control.Join(joinData).Value;

            // ASSERT
            Assert.IsNotNull(result);

            var success = result.Success;

            Assert.IsTrue(success);

            Assert.AreEqual(10, game.GetActivePlayerCount());
        }
Пример #3
0
        public void TestJoinEleventhPlayer()
        {
            game.AddPlayer("Player One");
            game.AddPlayer("Player Two");
            game.AddPlayer("Player Three");
            game.AddPlayer("Player Four");
            game.AddPlayer("Player Five");
            game.AddPlayer("Player Six");
            game.AddPlayer("Player Seven");
            game.AddPlayer("Player Eight");
            game.AddPlayer("Player Nine");
            game.AddPlayer("Player Ten");

            JoinData joinData = new JoinData {
                name = "My name"
            };
            var result = control.Join(joinData).Value as FailResult;

            // ASSERT
            Assert.IsNotNull(result);
            Console.WriteLine(result.Message);
            Assert.IsFalse(result.Success);

            Assert.AreEqual(10, game.GetActivePlayerCount());
        }
Пример #4
0
        public async Task Join(JoinData data)
        {
            var role = data.PlayerIndex >= 0 ? "player " + (data.PlayerIndex + 1) : "watcher";

            _logger.LogInformation($"Got join request of {Context.ConnectionId} as {role} for room {data.RoomId}");
            _connectionManager.AddConnection(Context.ConnectionId, Clients.Caller, data);
            await BroadCastCurrentPlayersAsync(data.RoomId);

            _logger.LogInformation("Client subscribed!");
        }
Пример #5
0
 //http://localhost:5000/games/56bb18eb-fefb-4741-b834-eb5b0bfc657f/join
 public IActionResult Join(JoinData data)
 {
     try
     {
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #6
0
        public ActionResult <BaseResult> Join(JoinData data)
        {
            var chain = new CheckGamePhase(GamePhase.WaitingForPlayers)
                        .Then(new CheckCustomPredicate(g => g.GetActivePlayerCount() < 10, "Game player capacity exceeded"))
                        .Then(new ConcludeAndExecute(
                                  g => new JoinResult(g.AddPlayer(data.name))
                                  ));

            var game = Game.GetInstance();

            return(chain.ProcessChain(game));
        }
Пример #7
0
        public void TestJoinSuccess()
        {
            JoinData joinData = new JoinData {
                name = "My name"
            };
            var result = control.Join(joinData).Value;

            // ASSERT
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);

            Assert.AreEqual(1, game.GetActivePlayerCount());
        }
Пример #8
0
        public void TestJoinPhase(GamePhase gamePhase)
        {
            game.phase = gamePhase;

            JoinData joinData = new JoinData {
                name = "My name"
            };
            var result = control.Join(joinData).Value;

            // ASSERT
            Assert.IsNotNull(result);
            Assert.IsFalse(result.Success);

            Assert.AreEqual(0, game.GetActivePlayerCount());
        }
Пример #9
0
        // 회원가입 처리
        private static void AccountMakingHandler(byte[] msg, User client)
        {
            JoinData data = CustomProtocolManager.ParseJoinPacket(msg, 0, msg.Length);

            CustomProtocolManager.GenericResponseType response;

            if (ConDatabase.AccountMakeFunction(CustomProtocolManager.ParseJoinPacket(msg, 0, msg.Length)))
            {
                response = CustomProtocolManager.GenericResponseType.Acknowledge;
            }
            else
            {
                response = CustomProtocolManager.GenericResponseType.Denied;
            }

            SendToUser(client, CustomProtocolManager.MakeAuthTypeResponsePacket(response));
        }
Пример #10
0
        // 확인시 로직
        private void Confirm()
        {
            if (btn_JoinNameCheck.Enabled == true)
            {
                MessageBox.Show("ID 중복 여부를 확인해주십시오.", "절차 안내", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            if (btn_JoinNicknameCheck.Enabled == true)
            {
                MessageBox.Show("Nickname 중복 여부를 확인해주십시오.", "절차 안내", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            JoinData data = new JoinData()
            {
                user_id       = txt_JoinName.Text,
                user_password = txt_JoinPassword.Text,
                user_email    = txt_JoinEmail.Text,
                nickname      = txt_JoinNickname.Text,
                user_gender   = rb_JoinWoman.Checked
            };

            if (!MessageHandler.MakeAccount(data))
            {
                if (!ConnectInfo.getInstance().tcpClient.Client.Connected)
                {
                    MessageBox.Show("서버와 연결이 끊어졌습니다. 연결상태를 확인하십시오.\n연결상태에 문제가 없다면 서버가 오프라인이 되었을 가능성이 있습니다."
                                    , "연결 오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                    return;
                }

                MessageBox.Show("계정을 생성하지 못했습니다. \n절차상에 문제가 생겼거나 누군가가 먼저 ID나 닉네임을 선점했을 가능성이 있습니다.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            MessageBox.Show("계정 생성에 성공하였습니다. 생성하신 계정으로 로그인해주십시오!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

            id  = txt_JoinName.Text;
            pwd = txt_JoinPassword.Text;

            DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #11
0
        public async Task StartAsync()
        {
            try
            {
                _connectionStateChangedCallback(ConnectionState.Connecting);
                await _connection.StartAsync();

                _connectionStateChangedCallback(ConnectionState.Connected);
                var data = new JoinData {
                    RoomId = Room, PlayerIndex = PlayerIndex
                };
                await _connection.SendAsync(nameof(IGameHub.Join), data);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error starting {nameof(GameClient)}: {ex}");
                _connectionStateChangedCallback(ConnectionState.Disconnected);
            }
        }
Пример #12
0
        public static object  JoinAdd(JoinData item)
        {
            string strsql = @"INSERT  into Tbl_Joindata( status,ticketkind, Articleid,ord_code)   values
                ( @status,@ticketkind, @Articleid ,@ord_code) ";

            NameValueCollection nvc = new NameValueCollection            {
                { "status", "1" },
                { "ticketkind", item.TicketKind },
                { "Articleid", item.Articleid.ToString() },
                { "ord_code", item.Ord_code }
            };

            DbControl.Data_add(strsql, nvc);
            int joinid = 0;

            strsql = "select max (joinid) from  Tbl_Joindata";
            nvc.Clear();
            DataTable dt = DbControl.Data_Get(strsql, nvc);

            joinid  = (int)dt.Rows[0][0];
            item.Id = joinid;
            foreach (JoinDetail j in item.JoinDetail)
            {
                strsql = @"INSERT INTO tbl_joindetail( username, phone, email,
                    lessonid,amount,status,postion,unitname,joinid)
                        VALUES ( @username, @phone, @email, @lessonid,@amount,'Y',
                    @postion,@unitname,@joinid)";
                nvc.Clear();
                nvc.Add("joinid", joinid.ToString());
                nvc.Add("username", j.Name);
                nvc.Add("phone", j.Phone);
                nvc.Add("email", j.Email);
                nvc.Add("amount", j.Amount.ToString());
                nvc.Add("lessonid", j.LessonId.ToString());
                nvc.Add("postion", j.Postion);
                nvc.Add("unitname", j.Unitname);

                DbControl.Data_add(strsql, nvc);
            }
            ;

            return(item);
        }
Пример #13
0
    /// <summary>
    /// 회원가입 패킷을 만듭니다. JoinData 구조체를 담습니다.
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public static byte[] MakeJoinPacket(JoinData data)
    {
        byte[] packet;
        byte[] dataByte;

        XmlSerializer xs = new XmlSerializer(typeof(JoinData));

        using (MemoryStream ms = new MemoryStream())
        {
            xs.Serialize(ms, data);
            dataByte = ms.ToArray();
        }


        packet = new byte[HEADER_SIZE + dataByte.Length];

        Array.Copy(MakeHeader(dataByte.Length, TypeNumber.Authorization, (byte)AuthorizationOption.JoinDataPacket), 0, packet, 0, HEADER_SIZE);
        Array.Copy(dataByte, 0, packet, HEADER_SIZE, dataByte.Length);

        return(packet);
    }
 public int JoinGroups([FromBody] JoinData data)
 {
     Log.Instance.Error("groups: " + data.GroupNames);
     string[] groups = data.GroupNames.Split(',');
     foreach (var grp in groups)
     {
         Log.Instance.Info("group: " + grp);
     }
     foreach (var groupName in groups)
     {
         var userGroup = _userGroups.GetOrAdd(groupName, new UserGroup()
         {
             Users = new ConcurrentBag <Guid>()
         });
         if (!userGroup.Users.Contains(data.UserId))
         {
             userGroup.Users.Add(data.UserId);
             Log.Instance.Info(data.UserId + " Added To " + groupName);
         }
     }
     return(groups.Length);
 }
Пример #15
0
        /// <summary>
        /// 계정을 만들어달라고 요청합니다. 성공 여부가 반환됩니다.
        /// </summary>
        /// <param name="data">계정 양식입니다.</param>
        /// <returns>성공 여부</returns>
        public static bool MakeAccount(JoinData data)
        {
            ConnectInfo ci = ConnectInfo.getInstance();

            SendToServer(CustomProtocolManager.MakeJoinPacket(data), true);
            int index          = 0;
            int requiredLength = CustomProtocolManager.HEADER_SIZE + 1;

            byte[] recvData = new byte[requiredLength];

            if (!ReceiveFunction(ci.tcpClient.Client, ref recvData, ref index, requiredLength))
            {
                return(false);
            }

            if (CustomProtocolManager.ParseResponsePacket(recvData, CustomProtocolManager.HEADER_SIZE)
                == CustomProtocolManager.GenericResponseType.Acknowledge)
            {
                return(true);
            }
            return(false);
        }
Пример #16
0
        // TOOD: return result and handle errors in caller.
        public void AddConnection(string connectionId, IGameClient client, JoinData data)
        {
            if (string.IsNullOrWhiteSpace(data.RoomId))
            {
                return;
            }
            var room = _roomRepo.FindByName(data.RoomId);

            if (room == null)
            {
                Console.WriteLine($"Room '{data.RoomId}' not found, ignoring join.");
                return;
            }

            var lobby = _lobbyRepo.GetLobbyFor(room);

            ResetPreviousLobbyAssignment(connectionId);

            var sender = new GameEventForwarder(client, data.PlayerIndex);

            sender.SubscribeTo(lobby);
            _lobbyAssignments.Add(connectionId, new ClientToLobbyAssignment(lobby, data.PlayerIndex, sender));
        }
Пример #17
0
 /// <summary>
 /// 계정을 만듭니다.
 /// </summary>
 /// <param name="data">회원가입 양식을 의미합니다.</param>
 /// <returns>성공 여부를 의미합니다.</returns>
 public static bool AccountMakeFunction(JoinData data)
 {
     return(DBmanager.getInstance().MakeAccount(data));
 }
Пример #18
0
 public void OnJoin(JoinData joinData, JoinType type)
 {
     Logs.text += "OnJoin : " + JsonConvert.SerializeObject(joinData) + "\n\n";
 }
 public int JoinGroups([FromBody] JoinData data)
 {
     return(UserCache.Instance.JoinGroups(data));
 }