Esempio n. 1
0
        public Request SetLoginStatus(string id)
        {
            var request = CreateMsg.CreateRequest("online", "userStatus");

            request.SendUser = id;
            return(request);
        }
Esempio n. 2
0
        public HttpResponseMessage GetSchMsgs([FromBody] GetSchMsg m)
        {
            var filter = new BsonDocument();

            filter.Add("sid", m.SchoolID);
            int Count = MongoDbHelper.GetCount <Msg_S>(DbName.Msg_S, filter);

            if (Count == 0)
            {
                return(ResultHelper.OK(new List <string>()));
            }
            var ms = MongoDbHelper.GetPagedList2 <Msg_S, string>(DbName.Msg_S, m.Skip, m.Limit, filter, w => w.pt);//分页查找所有消息
            List <CreateMsg> lm = new List <CreateMsg>();

            for (int i = 0; i < ms.Count; i++)
            {
                var       jm = MongoDbHelper.FindOne <Msg_J>(ms[i].pid.ToString(), DbName.Msg_J);   //父消息
                var       u  = MongoDbHelper.QueryOne <U_Info>(DbName.U_Info, w => w._id == jm.pp); //发布者信息
                CreateMsg mg = new CreateMsg();
                mg.ID          = ms[i]._id.ToString();
                mg.Title       = jm.tt;
                mg.PublishName = u.pnm;
                mg.Time        = ms[i].pt;
                mg.IsRead      = ms[i].ir;
                mg.Content     = jm.ct;
                mg.Urls        = jm.urls;
                lm.Add(mg);
            }
            return(ResultHelper.OK(new { Data = lm, Count = Count }));
        }
Esempio n. 3
0
        private void OnClose(IWebSocketConnection socket)
        {
            var un = socket.GetPaarmiter(username);

            userlist.Remove(un);
            CreateMsg.Run(updatelist());
        }
Esempio n. 4
0
        public HttpResponseMessage CreateMsg([FromBody] CreateMsg m)
        {
            var users = MongoDbHelper.QueryBy <U_Info>(DbName.U_Info, w => w.tp == 1);

            Msg_J j = new Msg_J();

            j._id  = ObjectId.GenerateNewId();
            j.tt   = m.Title;
            j.pp   = m.PublishID;
            j.pt   = m.Time;
            j.ct   = m.Content;
            j.urls = m.Urls;
            MongoDbHelper.Insert(j, DbName.Msg_J);
            List <Msg_S> ls = new List <Msg_S>();

            for (int i = 0; i < users.Count; i++)
            {
                Msg_S s = new Msg_S();
                s.sid = users[i]._id;
                s.pid = j._id;
                s.ir  = 0;
                s.pt  = j.pt;
                ls.Add(s);
            }
            MongoDbHelper.Insert(ls, DbName.Msg_S);
            return(ResultHelper.OK());
        }
Esempio n. 5
0
        private void Open(IWebSocketConnection socket)
        {
            var v = socket.GetPaarmiter(username);

            //如果未取到用户名,则断开连接
            if (string.IsNullOrWhiteSpace(v))
            {
                socket.Close();
                return;
            }
            if (!userlist.ContainsKey(v))
            {
                userlist.Add(v, socket);
                CreateMsg.Run(updatelist());
            }
            else
            {
                var n = CreateMsg.CreateMsgRequest("在其他地方登入");
                n.RecUserlist.Add(v);
                CreateMsg.Run(n);
                userlist[v].Close();
                userlist.Add(v, socket);
                CreateMsg.Run(updatelist());
            }
        }
Esempio n. 6
0
 public override void RegisterServieceRequest(ServiceRegister Register)
 {
     Register.Register("System.CountUser",
                       (Request parameter, ref Request result) =>
     {
         var res = CreateMsg.CreateRequest(GetCount(), new RequestType()
         {
             Other = "System.CountUser"
         });
         res.SendUser = "******";
         result       = res;
         res.RecUserlist.Add(parameter.SendUser);
         socket.Send(res);
     });
     Register.Register("System.GetUserList",
                       (Request parameter, ref Request result) =>
     {
         Request request = (Request)parameter;
         var res         = CreateMsg.CreateRequest(GetCount(), new RequestType()
         {
             Other = "System.GetUserList"
         });
         res.Content     = GetUserList();
         res.SendUser    = "******";
         res.RecUserlist = request.RecUserlist;
         result          = res;
         socket.Send(res);
     });
 }
        public static void RequestEntityCreate(MyObjectBuilder_EntityBase entityBuilder)
        {
            var msg = new CreateMsg()
            {
                ObjectBuilder = entityBuilder,
            };

            MySession.Static.SyncLayer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
        }
Esempio n. 8
0
    // Use this for initialization
    void Start()
    {
        if (!instance)
        {
            instance = this;
        }

        init();
    }
Esempio n. 9
0
        public static void AddProductLine(CreateMsg cm, GameMsgType nType)
        {
            if (s_MsgObjMap.ContainsKey(nType))
            {
                Debug.LogError("register repeat message create func, msg type: " + nType);
            }

            s_MsgObjMap[nType] = cm;
        }
Esempio n. 10
0
        public Request updatelist()
        {
            var v = CreateMsg.CreateRequest("", new RequestType()
            {
                type = "System.GetUserList"
            });

            v.RecUserlist.AddRange(userlist.Keys.ToArray());
            return(v);
        }
Esempio n. 11
0
 static void OnMessage(ref CreateMsg msg, MyNetworkClient sender)
 {
     MySandboxGame.Log.WriteLine("CreateMsg: " + msg.ObjectBuilder.GetType().Name.ToString() + " EntityID: " + msg.ObjectBuilder.EntityId.ToString("X8"));
     MyEntities.CreateFromObjectBuilderAndAdd(msg.ObjectBuilder);
     MySandboxGame.Log.WriteLine("Status: Exists(" + MyEntities.EntityExists(msg.ObjectBuilder.EntityId) + ") InScene(" + ((msg.ObjectBuilder.PersistentFlags & MyPersistentEntityFlags2.InScene) == MyPersistentEntityFlags2.InScene) + ")");
     if (Sync.IsServer)
     {
         MySession.Static.SyncLayer.SendMessageToAll(ref msg);
     }
 }
Esempio n. 12
0
        public static void RequestEntityCreate(MyObjectBuilder_EntityBase entityBuilder)
        {
            Debug.Fail("Use replication instead of this!");
            var msg = new CreateMsg()
            {
                ObjectBuilder = entityBuilder,
            };

            MySession.Static.SyncLayer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
        }
        /// <summary>
        /// Create CreateMsg object
        /// </summary>
        /// <param name="coList">RNObject List</param>
        /// <returns> CreateMsg</returns>
        private CreateMsg getCreateMsg(List <RNObject> coList)
        {
            CreateMsg createMsg = new CreateMsg();
            CreateProcessingOptions createProcessingOptions = new CreateProcessingOptions();

            createProcessingOptions.SuppressExternalEvents = true;
            createProcessingOptions.SuppressRules          = true;
            createMsg.ProcessingOptions = createProcessingOptions;
            createMsg.RNObjects         = coList.ToArray();
            return(createMsg);
        }
Esempio n. 14
0
 public static INetWorkMessage CreateMsgByType(GameMsgType nType)
 {
     if (s_MsgObjMap.ContainsKey(nType))
     {
         CreateMsg cm = (CreateMsg)s_MsgObjMap[nType];
         return(cm());
     }
     else
     {
         Debug.LogError("register none message create func, msg type: " + nType);
         return(new GameMsgBase(nType));
     }
 }
Esempio n. 15
0
        /// <summary>
        /// websocket注册
        /// </summary>
        public void WebsocketRegedit()
        {
            UseSocket use = UseSocket.CreateSocket();

            use.Message = (username, Message) =>
            {
                var result = JsonConvert.DeserializeObject <Request>(Message);
                if (result.ClientType.type == "File")
                {
                    var item = CreateMsg.Run(result);
                    use.CreatStream(username, (UpFileInfo)item.Content);
                }
                else
                {
                    CreateMsg.Run(result);
                }
            };
            use.BinaryMessage = (username, key) =>
            {
                use.listfs[username].Write(key);
            };
        }
Esempio n. 16
0
 static void OnMessage(ref CreateMsg msg, MyNetworkClient sender)
 {
     Debug.Fail("Use replication instead of this!");
     MySandboxGame.Log.WriteLine("CreateMsg: Type: " + msg.ObjectBuilder.GetType().Name.ToString() + "  Name: " + msg.ObjectBuilder.Name + "  EntityID: " + msg.ObjectBuilder.EntityId.ToString("X8"));
     MyEntities.CreateFromObjectBuilderAndAdd(msg.ObjectBuilder);
     MySandboxGame.Log.WriteLine("Status: Exists(" + MyEntities.EntityExists(msg.ObjectBuilder.EntityId) + ") InScene(" + ((msg.ObjectBuilder.PersistentFlags & MyPersistentEntityFlags2.InScene) == MyPersistentEntityFlags2.InScene) + ")");
     if (Sync.IsServer)
         MySession.Static.SyncLayer.SendMessageToAll(ref msg);
 }
Esempio n. 17
0
 public static void RequestEntityCreate(MyObjectBuilder_EntityBase entityBuilder)
 {
     Debug.Fail("Use replication instead of this!");
     var msg = new CreateMsg() { ObjectBuilder = entityBuilder, };
     MySession.Static.SyncLayer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
 }
Esempio n. 18
0
 static void OnMessage(ref CreateMsg msg, MyNetworkClient sender)
 {
     MySandboxGame.Log.WriteLine("CreateMsg: " + msg.ObjectBuilder.GetType().Name.ToString() + " EntityID: " + msg.ObjectBuilder.EntityId.ToString("X8"));
     MyEntities.CreateFromObjectBuilderAndAdd(msg.ObjectBuilder);
     MySandboxGame.Log.WriteLine("Status: Exists(" + MyEntities.EntityExists(msg.ObjectBuilder.EntityId) + ") InScene(" + ((msg.ObjectBuilder.PersistentFlags & MyPersistentEntityFlags2.InScene) == MyPersistentEntityFlags2.InScene) + ")");
 }
Esempio n. 19
0
		public static void RequestEntityCreate(MyObjectBuilder_EntityBase entityBuilder)
		{
			var msg = new CreateMsg() { ObjectBuilder = entityBuilder, };
			MySession.Static.SyncLayer.SendMessageToServer(ref msg, MyTransportMessageEnum.Request);
		}