Exemplo n.º 1
0
        public override void OnOpen()
        {
            this.userID = this.WebSocketContext.QueryString["userID"];

            WebSocketCollection wsClients = (WebSocketCollection)HttpContext.Current.Application["WSClients"];

            wsClients.Add(this);
            HttpContext.Current.Application["WSClients"] = wsClients;
            string loginResponse = new SlackMUDRPG.CommandClasses.SlackMud().Login(this.userID, false, null, "WS");

            if (loginResponse == null)
            {
                this.Send("Character not found?");
            }
            else if (loginResponse != "")
            {
                this.Send(loginResponse);
                new SMCommandUtility(this.userID).InitateCommand("look");
            }
            ;
        }
Exemplo n.º 2
0
        public GameConnection TryAddPlayer(GameWebSocketService client, string name)
        {
            lock (gameLock)
            {
                if (Started)
                {
                    return(null);
                }

                clients.Add(client);
                var player = new Player(name);
                game.AddPlayer(player);

                if (clients.Count == config.NumberOfPlayers)
                {
                    StartGame();
                }

                return(new GameConnection(client, player, this));
            }
        }
Exemplo n.º 3
0
 public override void OnOpen()
 {
     //this.Send("Welcome!" + this.WebSocketContext.User.Identity.Name);
     this.userId    = SessionUser.GetUserId();
     this.clientId  = Guid.NewGuid();
     this.userName  = this.WebSocketContext.User.Identity.Name;
     this.userColor = GetColor();
     //this.id = Convert.ToInt32(Cypher.Decrypt(this.WebSocketContext.QueryString["id"]));
     clients.Add(this);
     foreach (var item in clients)
     {
         if (item != this && ((APVTranslator_Web.Socket.wsHandler)item).projectId == this.projectId && ((APVTranslator_Web.Socket.wsHandler)item).fileId == this.fileId)
         {
             string msgBack = ((APVTranslator_Web.Socket.wsHandler)item).lastMessage;
             if (!string.IsNullOrEmpty(msgBack))
             {
                 this.Send(msgBack);
             }
         }
     }
     ;
 }
        public override void OnOpen()
        {
            stopWatch.Start();
            this.name = this.WebSocketContext.QueryString["username"];
            if (name == "")
            {
                name = "NoName";
            }
            clients.Add(this);

            _storeMessages = Task.Run(() => _service.GetAll()).Result;
            this.Send("<span style='color:grey;font-size: 15px;'>Welcome to CIMP Messenger</span>");
            foreach (var message in _storeMessages)
            {
                this.Send(string.Format("<span style='color:grey;font-size: 9px;'>{0} : {1}</span>", message.Name, message.Text));
            }
            this.Send("<hr/>");
            clients.Broadcast(string.Format("<strong><small> {0} joined. </small></strong>", name));
            stopWatch.Stop();
            sendtimestamp(string.Format("Open connection, Read & Send '{0}': <small>{1}ms</small>", this.name, stopWatch.Elapsed.TotalMilliseconds));
            stopWatch.Reset();
        }
Exemplo n.º 5
0
        public override void OnOpen()
        {
            base.OnOpen();
            WEB_SOCKET_CLIENTS.Add(this);

            LOGGER.Debug("WebServiceConnection to GateCampDetector opened");
            try
            {
                foreach (var curGateCamp in GateCampDetector.GateCamps)
                {
                    var gateCampMessage = new GateCampMessage
                    {
                        GateCampMessageType = GateCampMessageType.ADD,
                        GateCamp            = new GateCampMessageModel(curGateCamp)
                    };
                    Send(JsonConvert.SerializeObject(gateCampMessage));
                }
            }
            catch (Exception e)
            {
                LOGGER.Error("error in sending initial gatecamps", e);
                throw;
            }
        }
Exemplo n.º 6
0
 public override void OnOpen()
 {
     name = this.WebSocketContext.QueryString["chatName"];
     clients.Add(this);
     clients.Broadcast(name + " has connected.");
 }
 public override void OnOpen()
 {
     MessageClients.Add(this);
 }
Exemplo n.º 8
0
 public override void OnOpen()
 {
     client.Add(this);
 }
 public override void OnOpen()
 {
     _someClients.Add(this);
 }
Exemplo n.º 10
0
 public static void AddClient(TimeWSHandler wsClient)
 {
     clients.Add(wsClient);
 }
Exemplo n.º 11
0
 public override void OnOpen()
 {
     _chatClients.Add(this);
     _userRepository.Save(_user);
 }
Exemplo n.º 12
0
 public override void OnOpen()
 {
     ChatClients.Add(this);
     Broadcast(_message);
 }
Exemplo n.º 13
0
 public override void OnOpen()
 {
     name = this.WebSocketContext.QueryString["ChatName"];
     Clients.Add(this);
     Clients.Broadcast(name + " Has Connect.");
 }
Exemplo n.º 14
0
 public override void OnOpen()
 {
     this.name = this.WebSocketContext.QueryString["name"];
     chatClients.Add(this);
     chatClients.Broadcast("Client joined: " + name.ToString());
 }
Exemplo n.º 15
0
 public override void OnOpen()
 {
     _lastCommunication = DateTime.Now;
     _connections.Add(this);
 }
Exemplo n.º 16
0
 public override void OnOpen()
 {
     partidaClients.Add(this);
 }
Exemplo n.º 17
0
 public override void OnOpen()
 {
     _wsClients.Add(this);
     base.OnOpen();
 }
Exemplo n.º 18
0
 public override void OnOpen()
 {
     connections.Add(this);
 }
Exemplo n.º 19
0
 public override void OnOpen()
 {
     clients.Add(this);
     clients.Broadcast("Connected");
 }
Exemplo n.º 20
0
 public override void OnOpen()
 {
     salaClients.Add(this);
 }
 public override void OnOpen()
 {
     lock (Locker)
         ChatClients.Add(this);
 }
Exemplo n.º 22
0
        public override void OnOpen()
        {
            try
            {
                clients.Add(this);
                if (this.WebSocketContext.RequestUri.Query.Split(',')[1].Split(':').Contains("GroupId"))
                {
                    var GroupId = this.WebSocketContext.RequestUri.Query.Split(',')[1].Split(':')[1];
                    var UserId  = this.WebSocketContext.RequestUri.Query.Split(',')[0].Split(':')[1];
                    using (LystenEntities db = new LystenEntities())
                    {
                        int gid = Convert.ToInt32(GroupId);
                        int uid = Convert.ToInt32(UserId);

                        //var obj = db.Groups.Where(x => x.Id == gid).FirstOrDefault();
                        //if (obj.GroupTypeId == 1)
                        //{
                        //    if (!db.Groups.Any(x => x.CreatorId == uid && x.Id == gid))
                        //    {
                        //        if (!db.UserGroupMappings.Any(x => x.UserId == uid && x.GroupId == gid))
                        //        {
                        //            UserGroupMapping ugm = new UserGroupMapping()
                        //            {
                        //                GroupId = gid,
                        //                UserId = uid
                        //            };
                        //            db.UserGroupMappings.Add(ugm);
                        //            db.SaveChanges();
                        //        }
                        //    }
                        //}
                        WebSocketSessionDb webs = new WebSocketSessionDb();

                        if (db.WebSocketSessionDbs.Any(x => x.GroupID == gid && x.UserId == uid))
                        {
                            webs                 = db.WebSocketSessionDbs.Where(x => x.GroupID == gid && x.UserId == uid).FirstOrDefault();
                            webs.GroupID         = Convert.ToInt32(GroupId);
                            webs.UserId          = Convert.ToInt32(UserId);
                            webs.SessionId       = this.WebSocketContext.SecWebSocketKey;
                            db.Entry(webs).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                        else
                        {
                            webs.GroupID   = Convert.ToInt32(GroupId);
                            webs.UserId    = Convert.ToInt32(UserId);
                            webs.SessionId = this.WebSocketContext.SecWebSocketKey;
                            db.WebSocketSessionDbs.Add(webs);
                            db.SaveChanges();
                        }
                    }
                }
                else
                {
                    var ReceiptionId = this.WebSocketContext.RequestUri.Query.Split(',')[1].Split(':')[1];
                    var UserId       = this.WebSocketContext.RequestUri.Query.Split(',')[0].Split(':')[1];
                    using (LystenEntities db = new LystenEntities())
                    {
                        int rid = Convert.ToInt32(ReceiptionId);
                        int uid = Convert.ToInt32(UserId);


                        WebSocketSessionDb webs = new WebSocketSessionDb();

                        if (db.WebSocketSessionDbs.Any(x => x.RecipientId == rid && x.UserId == uid))
                        {
                            webs                 = db.WebSocketSessionDbs.Where(x => x.RecipientId == rid && x.UserId == uid).FirstOrDefault();
                            webs.RecipientId     = Convert.ToInt32(rid);
                            webs.UserId          = Convert.ToInt32(UserId);
                            webs.SessionId       = this.WebSocketContext.SecWebSocketKey;
                            db.Entry(webs).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                        else
                        {
                            webs.RecipientId = Convert.ToInt32(rid);
                            webs.UserId      = Convert.ToInt32(UserId);
                            webs.SessionId   = this.WebSocketContext.SecWebSocketKey;
                            db.WebSocketSessionDbs.Add(webs);
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonServices.ErrorLogging(ex);
            }
        }
Exemplo n.º 23
0
 public override void OnOpen()
 {
     //this.connectedUser.UserName = this.WebSocketContext.QueryString["UserName"];
     clients.Add(this);
     OnMessage("ConnectedUserList#" + this.GetConnectedUserListJson(clients));
 }
Exemplo n.º 24
0
 public override void OnOpen()
 {
     _clients.Add(this);
     ResendDataToClient();
 }
Exemplo n.º 25
0
 public override void OnOpen()
 {
     Sockets.Add(this);
 }
Exemplo n.º 26
0
 public override void OnOpen()
 {
     Sockets.Add(this);
     Sockets.Broadcast(MessagesHelper.Create(color: _user.Color, message: "joined.", type: "joined", from: _user.Name));
     Send(MessagesHelper.Create(color: _user.Color, message: "Welcome", type: "welcome", from: _user.Name));
 }
Exemplo n.º 27
0
 public override void OnOpen()
 {
     _notificationSocket.Add(this);
 }
 public TrashWebSocketHandler(string deviceId)
 {
     DeviceId = deviceId;
     Clients.Add(this);
 }
Exemplo n.º 29
0
 //7, 連線後把WebSocketHandler物件放入聊天室集合
 public override void OnOpen()
 {
     _chatClients.Add(this);
 }
Exemplo n.º 30
0
 //覆寫OnOpen事件,鑄造新的ChatWebSocketHandler時觸發
 public override void OnOpen()
 {
     _chatClients.Add(this);                 //加入目前連進來的人到chatclients中
 }