Beispiel #1
0
        public static bool WriteArticle(OnlineUser user, string content, int parent_no = 0)
        {
            if (string.IsNullOrEmpty(content))
            {
                user.Message("내용을 입력해주세요.");
                return(false);
            }
            MysqlNode menu_update = new MysqlNode(Program.mysqlOption, "INSERT INTO board (user_id, content, parent_no) VALUES (?user_id, ?content, ?parent_no)");

            menu_update["user_id"] = user.id;
            menu_update["content"] = content;
            if (parent_no == 0)
            {
                menu_update["parent_no"] = null;
            }
            else
            {
                menu_update["parent_no"] = parent_no;
            }
            long result = menu_update.ExecuteInsertQuery();

            if (result > 0)
            {
                if (parent_no == 0)
                {
                    JObject json = new JObject();
                    json["type"] = PacketType.WriteBoardItem;
                    json["item"] = ((JArray)GetList((int)result)["list"])[0];
                    OnlineUser.SendAll(json);
                }
                else
                {
                    user.Send(GetCommentList(parent_no));
                    List <int> RelatedUser = GetRelatedUser(parent_no);
                    foreach (int id in RelatedUser)
                    {
                        if (id != user.id) // 올린 사람은 제외
                        {
                            OnlineUser.Notify(id, "comment", (int)result, "내가 올린 게시글에 답변이 등록되었습니다.", "(" + user.name + ") " + content);
                        }
                    }
                }
                user.Message("등록에 성공했습니다.");
                return(true);
            }
            else
            {
                user.Message("등록에 실패했습니다.");
                return(false);
            }
        }
Beispiel #2
0
        public static void UpdateWaiting(OnlineUser user, int no, int time) // 0~1~2
        {
            // 수신 금지 목록에 등록
            OnlineUser.receive_waiting_user.Add(user.id);
            user.Message("소중한 정보 감사합니다.");

            MysqlNode node = new MysqlNode(Program.mysqlOption, "INSERT INTO waiting_data (restaurant_no, user_id, waiting) VALUES (?restaurant_no, ?user_id, ?waiting)");

            node["restaurant_no"] = no;
            node["user_id"]       = user.id;
            if (time < 2)
            {
                node["waiting"] = time * 5;
            }
            else
            {
                node["waiting"] = 15;
            }
            node.ExecuteNonQuery();
            int?result = AutoWaitingComputing.Update(no);

            foreach (int id in GetWaitingListener(no))
            {
                OnlineUser.Notify(id, "waiting", no, GetTitle(no) + " 대기 시간 수신", "예상 시간 : " + result.Value + "분");
            }
        }
Beispiel #3
0
        public static void AddWaitingListener(OnlineUser user, int no)
        {
            if (!get_waiting_queue.ContainsKey(no))
            {
                get_waiting_queue[no] = new CacheList <int>(1800);
            }
            get_waiting_queue[no].Add(user.id);
            // 결과 전송
            user.Send(GetContainsWaitingListener(user, no));
            user.Message("30분간 이 음식점의 대기열 정보를 직접 수신합니다.");

            // 다른 유저들에게 메세지 전송
            JObject json = new JObject();

            json["type"]  = PacketType.RequestWaitingToUser;
            json["no"]    = no;
            json["title"] = GetTitle(no);

            Position position = GetPosition(no);

            foreach (OnlineUser other_user in Program.users.Values)
            {
                if (other_user.position != null && other_user.position.DistanceToMeter(position) < 256)
                {
                    if (!OnlineUser.receive_waiting_user.Contains(other_user.id))
                    {
                        other_user.Send(json);
                    }
                }
            }
        }
Beispiel #4
0
        public void MessageSendTestMethod()
        {
            OnlineUser user = new OnlineUser(null);

            try
            {
                user.Message("");
                Assert.Fail("연결 소켓이 없지만 메세지 전송 에러 없음");
            }
            catch (Exception e)
            {
            }
        }
Beispiel #5
0
        public static void ClickLike(OnlineUser user, int restaurant_no)
        {
            MysqlNode node   = new MysqlNode(Program.mysqlOption, "DELETE FROM rest_likes_data where restaurant_no = ?restaurant_no AND user_id = ?user_id");
            int       result = 0;

            node["restaurant_no"] = restaurant_no;
            node["user_id"]       = user.id;
            result += node.ExecuteNonQuery();
            if (result == 0)
            {
                node.ChangeSql("INSERT INTO rest_likes_data (restaurant_no, user_id) VALUES (?restaurant_no, ?user_id)");
                result += node.ExecuteNonQuery();
            }
            if (result > 0)
            {
                user.Send(StateLikes(user, restaurant_no));
            }
            else
            {
                user.Message("요청이 실패했습니다.");
            }
        }