Пример #1
0
        public override void ExecuteCommand(string userId, string command)
        {
            ServerApplicationStatus appStatusData = deserialize.Deserialize <ServerApplicationStatus>(command);

            if (appStatusData == null)
            {
                return;
            }

            List <ApplicationModel> appModelList = new List <ApplicationModel>();

            foreach (ApplicationEntry entry in appStatusData.UserApplicationList)
            {
                ApplicationModel model = new ApplicationModel()
                {
                    AppliationId    = entry.Identifier,
                    ApplicationName = entry.Name,
                };

                appModelList.Add(model);
            }

            ApplicationSettings.GetInstance().ApplicationList = appStatusData.UserApplicationList;
            client.RefreshAppList(appModelList);
        }
Пример #2
0
        private void onApplicationEdited(int appId)
        {
            Dictionary <int, string> userList = getUsersSocketListByAppId(appId);

            foreach (KeyValuePair <int, string> dbSocketPair in userList)
            {
                List <ApplicationEntry> appsEntries = new List <ApplicationEntry>();
                List <ApplicationData>  appDataList = new List <ApplicationData>(Server.ServerDbHelper.GetInstance().GetAppsWithUserId(dbSocketPair.Key));
                foreach (ApplicationData data in appDataList)
                {
                    appsEntries.Add(new ApplicationEntry()
                    {
                        Identifier = data.id,
                        Name       = data.name
                    });
                }

                // notify new application list
                ServerApplicationStatus appStatus = new ServerApplicationStatus()
                {
                    UserApplicationList = appsEntries,
                };

                connectionManager.SendData(
                    (int)CommandConst.MainCommandServer.UserPriviledge,
                    (int)CommandConst.SubCommandServer.ApplicationList,
                    appStatus,
                    new List <string>()
                {
                    dbSocketPair.Value
                });
            }
        }
Пример #3
0
        private void onApplicationRemoved(int appId)
        {
            // TODO: should notify client with this appId only
            IList <ClientInfoModel> userList = new List <ClientInfoModel>(Server.ConnectedClientHelper.GetInstance().GetAllUsers());

            foreach (ClientInfoModel clientInfo in userList)
            {
                // notify new application list
                ServerApplicationStatus appStatus = new ServerApplicationStatus()
                {
                    UserApplicationList = Server.ServerDbHelper.GetInstance().GetAppsWithUserId(clientInfo.DbUserId).Select(
                        t => new ApplicationEntry()
                    {
                        Identifier = t.id,
                        Name       = t.name
                    }).ToList(),
                };

                connectionManager.SendData(
                    (int)CommandConst.MainCommandServer.UserPriviledge,
                    (int)CommandConst.SubCommandServer.ApplicationList,
                    appStatus,
                    new List <string>()
                {
                    clientInfo.SocketUserId
                });
            }
        }
Пример #4
0
        private void onGroupEdited(int groupId)
        {
            GroupData latestData = Server.ServerDbHelper.GetInstance().GetAllGroups().First(groupData => groupData.id == groupId);

            ServerViewingAreaStatus viewingArea = new ServerViewingAreaStatus();
            MonitorInfo             monitorInfo = null;

            if (latestData.share_full_desktop)
            {
                monitorInfo = getDesktopMonitorInfo();
            }
            else
            {
                monitorInfo = getUserMonitorInfo(groupId);
            }

            viewingArea.ViewingArea = monitorInfo;


            ServerMaintenanceStatus maintenanceCmd = new ServerMaintenanceStatus();

            maintenanceCmd.AllowMaintenance   = latestData.allow_maintenance;
            maintenanceCmd.AllowRemoteControl = latestData.allow_remote;

            ServerApplicationStatus appCmd          = new ServerApplicationStatus();
            List <ApplicationEntry> applicationList = new List <ApplicationEntry>();

            foreach (ApplicationData appData in Server.ServerDbHelper.GetInstance().GetAppsWithGroupId(groupId))
            {
                applicationList.Add(new ApplicationEntry()
                {
                    Identifier = appData.id,
                    Name       = appData.name
                });
            }
            appCmd.UserApplicationList = applicationList;

            // send update to all users
            List <string> usersList = getSocketIdentifierFromGroupId(groupId);

            connectionManager.SendData(
                (int)CommandConst.MainCommandServer.UserPriviledge,
                (int)CommandConst.SubCommandServer.ViewingArea,
                viewingArea,
                usersList);

            connectionManager.SendData(
                (int)CommandConst.MainCommandServer.UserPriviledge,
                (int)CommandConst.SubCommandServer.Maintenance,
                maintenanceCmd,
                usersList);

            connectionManager.SendData(
                (int)CommandConst.MainCommandServer.UserPriviledge,
                (int)CommandConst.SubCommandServer.ApplicationList,
                appCmd,
                usersList);
        }
Пример #5
0
        private void sendLoginReply(Server.Model.ClientInfoModel model, int dekstopRow, int desktopCol)
        {
            // get server's monitor info
            List <Session.Data.SubData.MonitorInfo> monitorList = new List <MonitorInfo>();
            int desktopLeft   = 0;
            int desktopTop    = 0;
            int desktopRight  = 0;
            int desktopBottom = 0;

            foreach (WindowsHelper.MonitorInfo monitor in Utils.Windows.WindowsHelper.GetMonitorList())
            {
                if (desktopLeft > monitor.WorkArea.Left)
                {
                    desktopLeft = monitor.MonitorArea.Left;
                }

                if (desktopTop > monitor.WorkArea.Top)
                {
                    desktopTop = monitor.MonitorArea.Top;
                }

                if (desktopRight < monitor.WorkArea.Right)
                {
                    desktopRight = monitor.MonitorArea.Right;
                }

                if (desktopBottom < monitor.WorkArea.Bottom)
                {
                    desktopBottom = monitor.MonitorArea.Bottom;
                }

                monitorList.Add(new Session.Data.SubData.MonitorInfo()
                {
                    LeftPos   = monitor.MonitorArea.Left,
                    TopPos    = monitor.MonitorArea.Top,
                    RightPos  = monitor.MonitorArea.Right,
                    BottomPos = monitor.MonitorArea.Bottom
                });
            }

            // send user data to client
            UserSettingData settingData = Server.ServerDbHelper.GetInstance().GetUserSetting(model.DbUserId);

            Session.Data.ServerUserSetting userSetting = new ServerUserSetting()
            {
                UserSetting = new UserSetting()
                {
                    gridX  = settingData.gridX,
                    gridY  = settingData.gridY,
                    isSnap = settingData.isSnap,
                }
            };

            // get user's application list
            ServerApplicationStatus serverAppStatus = new ServerApplicationStatus();

            serverAppStatus.UserApplicationList = new List <ApplicationEntry>();
            foreach (ApplicationData appData in Server.ServerDbHelper.GetInstance().GetAppsWithUserId(model.DbUserId))
            {
                serverAppStatus.UserApplicationList.Add(new ApplicationEntry()
                {
                    Identifier = appData.id,
                    Name       = appData.name
                });
            }

            // get user's preset list
            ServerPresetsStatus serverPresetStatus = new ServerPresetsStatus();

            serverPresetStatus.UserPresetList = new List <PresetsEntry>();
            foreach (PresetData presetData in Server.ServerDbHelper.GetInstance().GetPresetByUserId(model.DbUserId))
            {
                List <ApplicationEntry> presetAppEntries = new List <ApplicationEntry>();
                foreach (ApplicationData appData in presetData.AppDataList)
                {
                    presetAppEntries.Add(new ApplicationEntry()
                    {
                        Identifier = appData.id,
                        Name       = appData.name
                    });
                }

                List <VncEntry> presetVncEntries = new List <VncEntry>();
                foreach (RemoteVncData vncData in presetData.VncDataList)
                {
                    presetVncEntries.Add(new VncEntry()
                    {
                        Identifier  = vncData.id,
                        DisplayName = vncData.name,
                        IpAddress   = vncData.remoteIp,
                        Port        = vncData.remotePort,
                    });
                }

                // get all vision inputs
                List <InputAttributes> allInputList = Server.ServerVisionHelper.getInstance().GetAllVisionInputsAttributes();
                List <InputAttributes> inputEntries = new List <InputAttributes>();
                foreach (VisionData inputData in presetData.InputDataList)
                {
                    inputEntries.Add(new InputAttributes()
                    {
                        InputId     = inputData.id,
                        DisplayName = allInputList.First(inputAtt => inputAtt.InputId == inputData.id).DisplayName,
                    });
                }

                serverPresetStatus.UserPresetList.Add(new PresetsEntry()
                {
                    Identifier      = presetData.Id,
                    Name            = presetData.Name,
                    ApplicationList = presetAppEntries,
                    VncList         = presetVncEntries,
                    InputList       = inputEntries,
                });
            }

            // get user's priviledge
            ServerMaintenanceStatus maintenanceStatus = new ServerMaintenanceStatus();
            GroupData groupData = Server.ServerDbHelper.GetInstance().GetGroupByUserId(model.DbUserId);

            maintenanceStatus.AllowMaintenance   = groupData.allow_maintenance;
            maintenanceStatus.AllowRemoteControl = groupData.allow_remote;

            MonitorInfo allowViewingArea = new MonitorInfo();

            if (groupData.share_full_desktop)
            {
                // same as full desktop
                allowViewingArea.LeftPos   = desktopLeft;
                allowViewingArea.TopPos    = desktopTop;
                allowViewingArea.RightPos  = desktopRight;
                allowViewingArea.BottomPos = desktopBottom;
            }
            else
            {
                // get monitor info
                MonitorData monitorData = Server.ServerDbHelper.GetInstance().GetMonitorByGroupId(groupData.id);

                allowViewingArea.LeftPos   = monitorData.Left;
                allowViewingArea.TopPos    = monitorData.Top;
                allowViewingArea.RightPos  = monitorData.Right;
                allowViewingArea.BottomPos = monitorData.Bottom;
            }

            // prepare the VNC list
            ServerVncStatus vncStatus  = new ServerVncStatus();
            List <VncEntry> vncEntries = new List <VncEntry>();

            vncStatus.UserVncList = vncEntries;
            foreach (RemoteVncData vncData in ServerDbHelper.GetInstance().GetRemoteVncList())
            {
                vncEntries.Add(new VncEntry()
                {
                    Identifier  = vncData.id,
                    DisplayName = vncData.name,
                    IpAddress   = vncData.remoteIp,
                    Port        = vncData.remotePort,
                });
            }

            ServerLoginReply reply = new ServerLoginReply()
            {
                LoginName    = model.Name,
                UserId       = model.DbUserId,
                ServerLayout = new ServerScreenInfo()
                {
                    MatrixCol          = desktopCol,
                    MatrixRow          = dekstopRow,
                    ServerMonitorsList = monitorList
                },
                // UserApplications
                UserApplications = serverAppStatus,

                // UserPresets
                UserPresets = serverPresetStatus,

                // UserMaintenance
                UserMaintenance = maintenanceStatus,

                // allowed viewing area
                ViewingArea = allowViewingArea,

                // Current vnc list
                VncStatus = vncStatus,

                // user settings
                UserSetting = userSetting,
            };

            connectionMgr.SendData(
                (int)CommandConst.MainCommandServer.UserPriviledge,
                (int)CommandConst.SubCommandServer.DisplayInfo,
                reply,
                new List <string>()
            {
                model.SocketUserId
            });


            // send Input info to client
            Session.Data.ServerInputStatus inputStatus = new Session.Data.ServerInputStatus()
            {
                InputAttributesList = Server.ServerVisionHelper.getInstance().GetAllVisionInputsAttributes(),
            };

            connectionMgr.SendData(
                (int)CommandConst.MainCommandServer.Presents,
                (int)CommandConst.SubCommandServer.VisionInput,
                inputStatus,
                new List <string>()
            {
                model.SocketUserId
            });
        }