コード例 #1
0
        public static void KakaoLogin(OnlineUser user, string token)
        {
            JObject message = new JObject();

            message["type"] = PacketType.Login;
            try
            {
                user.Login(token);

                message["result"]  = true;
                message["name"]    = user.name;
                message["icon"]    = user.img;
                message["id"]      = user.id;
                message["message"] = "success";
            }
            catch (Exception e)
            {
                message["result"]  = false;
                message["message"] = e.Message;
            }
            user.Send(message);
        }
コード例 #2
0
        private static void Server_Receive(ESocket socket, JObject Message)
        {
            OnlineUser user = users[socket];

            LogSystem.AddLog(-1, "Program - Receive", Message.ToString());
            switch ((int)Message["type"])
            {
            case PacketType.Login:
                KakaoModule.KakaoLogin(user, (string)Message["token"]);
                break;

            case PacketType.Debug:
                LogSystem.AddLog(0, "Program", (string)Message["message"]);
                break;

            case PacketType.RestaurantInfo:
                if (Message["no"] == null)
                {
                    user.Message("음식점 고유 번호값이 존재하지 않습니다.");
                }
                else
                {
                    JObject json = Module.Handler.Restaurant.Infomation((int)Message["no"]);
                    if (json == null)
                    {
                        user.Message("해당하는 번호의 음식점이 없습니다.");
                    }
                    else
                    {
                        user.Send(json);
                    }
                }
                break;

            case PacketType.RestaurantWaitingList:
                user.Send(Module.Handler.Restaurant.WaitingList());
                break;

            case PacketType.GetRestaurantID:
                user.Send(Module.Handler.Restaurant.GetID((string)Message["title"]));
                break;

            case PacketType.PositionUpdate:
                user.position = new Position(Message);
                break;

            case PacketType.ClickLikes:
                Module.Handler.Restaurant.ClickLike(user, (int)Message["no"]);
                break;

            case PacketType.GetLikes:
                user.Send(Module.Handler.Restaurant.StateLikes(user, (int)Message["no"]));
                break;

            case PacketType.RestaurantRankingList:
                user.Send(Module.Handler.Restaurant.RankingList((string)Message["category"]));
                break;

            case PacketType.ReadBoard:
                user.Send(Module.Handler.Board.GetList());
                break;

            case PacketType.WriteBoardItem:
                if (Message.ContainsKey("parent_no"))
                {
                    Module.Handler.Board.WriteArticle(user, (string)Message["content"], (int)Message["parent_no"]);
                }
                else
                {
                    Module.Handler.Board.WriteArticle(user, (string)Message["content"]);
                }
                break;

            case PacketType.ReadComments:
                user.Send(Module.Handler.Board.GetCommentList((int)Message["no"]));
                break;

            case PacketType.RequestWaitingToServer:
                Module.Handler.Restaurant.AddWaitingListener(user, (int)Message["no"]);
                break;

            case PacketType.ContainsWaitingListener:
                user.Send(Module.Handler.Restaurant.GetContainsWaitingListener(user, (int)Message["no"]));
                break;

            case PacketType.RequestWaitingToUser:
                Module.Handler.Restaurant.UpdateWaiting(user, (int)Message["no"], (int)Message["time"]);
                break;

            case PacketType.RestaurantRecommendList:
                user.Send(Module.Handler.Restaurant.RecommendList(user.position));
                break;
            }
        }