Ask Your Question
0

guid를 이용한 create

asked 2017-08-15 02:06:24 +0900

shkim gravatar image
      public static void OnAddUserPlayer(Session _Session, JObject _Message)
    {
        JObject response = new JObject();
        long playerIndex = (long)_Message.GetValue("PlayerIndex");

        Log.Info("add user player. teamnamefxcv, playerIndex{0}", playerIndex);

        // generate uid
        string playerId = Guid.NewGuid().ToString();

        Log.Info("creating user player {0}", playerId);

        // create player
        UserPlayer userPlayer = UserPlayer.Create(playerId);
        Log.Info("created user player");

....

위와 같은 형식으로 packet이 오면 NewGuid를 발급하고 그 Guid를 id로 써서 객체를 생성하려고 하는데, UserPlayer.Create가 return 하지 않습니다.

위 코드를 돌리면

I0815 01:57:50.721422 5553 (Mono)server.cs:282] creating user player cc11839455c84471938907c67ffc469e I0815 01:57:50.721727 5552 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.721786 5552 (Mono)server.cs:282] creating user player 8f9c09b4b001403e9c4ac2135e80cbe9 I0815 01:57:50.722074 5551 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.722136 5551 (Mono)server.cs:282] creating user player 94182fb8d07c4595a238a76c2773b454 I0815 01:57:50.722390 5550 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.722451 5550 (Mono)server.cs:282] creating user player ce06a561d3b74750ab43036ebac32b06 I0815 01:57:50.722720 5553 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.722781 5553 (Mono)server.cs:282] creating user player d193021182964c0cb1fb9033afc1c5db I0815 01:57:50.723052 5552 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.723114 5552 (Mono)server.cs:282] creating user player 83e2266920204f77bc6231bd3ad938d2 I0815 01:57:50.723367 5551 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.723428 5551 (Mono)server.cs:282] creating user player ef62d0ae80624e66bc1b4ea58f0d6a52 I0815 01:57:50.723702 5550 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.723762 5550 (Mono)server.cs:282] creating user player 16b605f2749f4573b43c56847d4d4b65 I0815 01:57:50.724040 5553 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.724102 5553 (Mono)server.cs:282] creating user player 465002687e214b3abb46bd76df4191cb I0815 01:57:50.724359 5552 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.724419 5552 (Mono)server.cs:282] creating user player d907f2ecc0274106a705c978e057450f I0815 01:57:50.724689 5551 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.724750 5551 (Mono)server.cs:282] creating user player fdb67df50d3a44059f62a7649f63eef1 I0815 01:57:50.725021 5550 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.725082 5550 (Mono)server.cs:282] creating user player 73bcbdfe46684bc18344334bc6f0ddf8 I0815 01:57:50.725378 5553 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.725438 5553 (Mono)server.cs:282] creating user player b20ea44b54034a26a9c2e43e019948ee I0815 01:57:50.725738 5552 (Mono)server.cs:263] add user player. teamnamefxcv, playerIndex2 I0815 01:57:50.725806 5552 (Mono)server.cs:282] creating user player bc29d27aaff14053af8d79a1f23e869c

이런식으로 계속해서 event callback이 불리기만 하다가 timeout이 나는데, 어떻게 수정하면 되나요?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2017-08-16 14:42:48 +0900

Seunghyun gravatar image

안녕하세요. 아이펀팩토리입니다.

Create() 함수로 전달되는 Key 값은, 해당 이벤트에서 생성하는 난수 값을 쓰시면 안됩니다. (롤백 후 다시 실행될 때 값이 매번 바뀌어 계속 롤백하게 됩니다.)

  1. Guid.NewGuid() 대신 funapi.RandomGenerator.GenerateUuid() 함수를 쓰시면 롤백 후 다시 실행될 때 같은 값을 반환하기 때문에 위 문제가 해결됩니다.

  2. 하지만 그 것 보다 "OnAddUserPlayer()" 함수에서 Guid 를 만들고 새로운 Event 함수에서 UserPlayer.Create() 함수를 호출하는 것을 더 권장합니다.(Guid 를 만든 후 Event.Invoke() 로 새 이벤트를 실행해 UserPlayer 를 만드는 것입니다.)

답변이 늦어 죄송합니다.

감사합니다.

edit flag offensive delete link more

Comments

아하! 시도해보겠습니다!

shkim gravatar imageshkim ( 2017-08-17 06:39:22 +0900 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-08-15 02:06:24 +0900

Seen: 112 times

Last updated: Aug 16 '17