public override void ExecuteCommand(string userId, string command) { ClientUserSettingCmd settingData = deserialize.Deserialize <ClientUserSettingCmd>(command); if (settingData == null) { return; } if (Server.ServerDbHelper.GetInstance().EditUserSetting(dbUserId, settingData.UserSetting.gridX, settingData.UserSetting.gridY, settingData.UserSetting.isSnap)) { ServerUserSetting userSetting = new ServerUserSetting() { UserSetting = new Session.Data.SubData.UserSetting() { gridX = settingData.UserSetting.gridX, gridY = settingData.UserSetting.gridY, isSnap = settingData.UserSetting.isSnap, } }; // TODO: should notify all connected login user with same id // notify user server.GetConnectionMgr().SendData( (int)CommandConst.MainCommandServer.UserPriviledge, (int)CommandConst.SubCommandServer.UserSetting, userSetting, new List <string>() { userId }); } }
public override void ExecuteCommand(string userId, string command) { ServerUserSetting settingData = deserialize.Deserialize <ServerUserSetting>(command); if (settingData == null) { return; } UserSettings.GetInstance().GridX = settingData.UserSetting.gridX; UserSettings.GetInstance().GridY = settingData.UserSetting.gridY; UserSettings.GetInstance().ApplySnap = settingData.UserSetting.isSnap; client.RefreshUserGridLayout(settingData.UserSetting); }
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 }); }