コード例 #1
0
 public void CreateConnectionRecordRoom(ConnectionRecordRoom t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<ConnectionRecordRoom>();
         rep.Insert(t);
     }
 }
コード例 #2
0
 public void CreateConnectionRecordRoom(ConnectionRecordRoom t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository <ConnectionRecordRoom>();
         rep.Insert(t);
     }
 }
コード例 #3
0
 public UserListRecords(ConnectionRecord cr, ConnectionRecordRoom cRr) : base(cr)
 {
     crr = cRr;
 }
コード例 #4
0
        /*
         * When a user connects we need to populate their user information, we default the username to be Anonymous + a #
         */

        //This method is to populate/join room
        public Task JoinRoom(Guid roomId, int moduleId)
        {
            //TODO: don't allow connecting to the same room twice
            var crc  = new ConnectionRecordController();
            var crrc = new ConnectionRecordRoomController();
            var rc   = new RoomController();

            var r = rc.GetRoom(roomId, moduleId);

            if (r.Enabled)
            {
                if (r.Private)
                {
                    //check the password
                }

                var c  = crc.GetConnectionRecordByConnectionId(Context.ConnectionId) ?? SetupConnectionRecord();
                var cr = crrc.GetConnectionRecordRoomByConnectionRecordId(c.ConnectionRecordId, roomId);



                if (cr == null)
                {
                    var crr = new ConnectionRecordRoom
                    {
                        ConnectionRecordId = c.ConnectionRecordId,
                        JoinDate           = DateTime.UtcNow,
                        DepartedDate       = null,
                        RoomId             = roomId
                    };

                    //join the room
                    crrc.CreateConnectionRecordRoom(crr);

                    var ulr = new UserListRecords(c, crr);

                    //add the user to the List of users that will be later filtered by RoomId
                    Users.Add(ulr);
                }

                Groups.Add(Context.ConnectionId, roomId.ToString());

                //populate history for all previous rooms
                RestoreHistory(roomId);

                //lookup the Room to get the Welcome Message
                Clients.Caller.newMessageNoParse(new Message
                {
                    AuthorName   = Localization.GetString("SystemName.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile),
                    ConnectionId = "0",
                    MessageDate  = DateTime.UtcNow,
                    MessageId    = -1,
                    MessageText  = r.RoomWelcome,
                    AuthorUserId = -1,
                    RoomId       = roomId
                });
                Clients.Group(roomId.ToString()).newMessageNoParse(new Message
                {
                    AuthorName = Localization.GetString("SystemName.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile)
                    ,
                    AuthorUserId = -1
                    ,
                    ConnectionId = "0",
                    MessageDate  = DateTime.UtcNow,
                    MessageId    = -1,
                    MessageText  = string.Format(Localization.GetString("Connected.Text", "~/desktopmodules/DnnChat/app_localresources/" + Localization.LocalSharedResourceFile), c.UserName),
                    RoomId       = roomId
                });

                Clients.Caller.scrollBottom(r.RoomId);

                return(Clients.Group(roomId.ToString()).updateUserList(Users.FindAll(uc => (uc.RoomId == r.RoomId)), roomId));
            }
            else
            {
                //if the room was no longer enabled, return nothing
                return(null);
            }
        }
コード例 #5
0
 public UserListRecords(ConnectionRecord cr, ConnectionRecordRoom cRr)
     : base(cr)
 {
     crr = cRr;
 }