void JoinServer(string clientName, ClientRole clientRole) { try { if (string.IsNullOrEmpty(serverHostname)) { print("Please specify UDP server !"); return; } var addresses = Dns.GetHostAddresses(serverHostname); serverEndpoint = new IPEndPoint(addresses[0], serverPort); serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); serverSocket.Bind(new IPEndPoint(IPAddress.Any, 0)); // TODO: Make this a string builder, and not a either/or switch string message = "JOIN" + "|" + clientRole + "|" + clientName + "|" + kinectSettings.Serialized; byte[] data = System.Text.Encoding.UTF8.GetBytes(message); serverSocket.SendTo(data, serverEndpoint); print("Server JOIN request sent"); } catch (Exception x) { print("Error: " + x.ToString()); } }
// TODO: Needs refactoring badly. public void RotateRolesKeepingAsPlayer(ClientRole keepAsPlayer) { var playerFormallyKnownAsX = _playerX; var playerFormallyKnownAsO = _playerO; var firstSpectator = _spectators.FirstOrDefault(); _playerX = null; _playerO = null; if (firstSpectator != null) { _spectators.Remove(firstSpectator); if (keepAsPlayer == ClientRole.PlayerX) { AssignToNextAvailableRole(firstSpectator); AssignToNextAvailableRole(playerFormallyKnownAsX); AssignToNextAvailableRole(playerFormallyKnownAsO); } else { AssignToNextAvailableRole(playerFormallyKnownAsO); AssignToNextAvailableRole(firstSpectator); AssignToNextAvailableRole(playerFormallyKnownAsX); } } else { AssignToNextAvailableRole(playerFormallyKnownAsO); AssignToNextAvailableRole(playerFormallyKnownAsX); } }
public ChatMessage(string _sendUserName, string _sendDisplayName, string _receieveUserName, string _message, ClientRole _userType, MessageType MessageType ) : this(_sendUserName, _sendDisplayName, _receieveUserName, _message, _userType) { this.MessageType = MessageType; }
// public ChatBoxContent Content { get; set; } public ChatMessage(string _sendUserName, string _sendDisplayName, string _receieveUserName, string _message, ClientRole _userType ) { this.SendUserName = _sendUserName; this.SendDisplayName = _sendDisplayName; this.ReceieveUserName = _receieveUserName; this.SendTime = DateTime.Now; this.Message = _message; UserType = _userType; }
private void AssignClientToRole(string clientId, ClientRole nextAvailableRole) { switch (nextAvailableRole) { case ClientRole.PlayerX: _playerX = clientId; break; case ClientRole.PlayerO: _playerO = clientId; break; case ClientRole.Spectator: _spectators.Add(clientId); break; } }
static void Main(string[] args) { SetCurrentProcessExplicitAppUserModelID("PeerFinderApp"); if (args[0] == "host") { HostRole host = new HostRole(); host.Run(); return; } ClientRole client = new ClientRole(); client.Run(); }
void LeaveServer(string clientName, ClientRole clientRole) { try { // TODO: Make this a string builder, and not a either/or switch string message = "LEAVE" + "|" + clientRole + "|" + clientName; byte[] data = System.Text.Encoding.UTF8.GetBytes(message); serverSocket.SendTo(data, serverEndpoint); print("Server LEAVE request sent"); } catch (Exception x) { print("Error: " + x.ToString()); } }
public async Task <IActionResult> EditCustomerRole(string id, ClientRole role) { var user = await _userManager.FindByIdAsync(id); if (user != null) { user.ClientRole = role; await _userManager.RemoveFromRoleAsync(user, user.ClientRole.ToString()); await _userManager.AddToRoleAsync(user, role.ToString()); var result = await _userManager.UpdateAsync(user); if (result.Succeeded) { return(Json(true)); } } return(Json(false)); }
public string Index(TextShow companyName, ClientRole clientRole) { var headMessage = t.GetString("Home"); return ($@"<script>document.title = '{headMessage}';</script> {ScriptingMessages()} <div id=""mainContainer"" class=""container""> <div id=""indexActions"" class=""row""> <div class=""col-lg""> </div> <div class=""col-lg""> <h2 class=""mt-5"">{t.GetString("Account")}</h2> <a class=""btn btn-outline-info d-block"" role=""button"" href=""/api/SignOut""> {t.GetString("Sign out")} </a> </div> </div> </div>"); }
public void Connect(string server, string userName = "******", int port = 20602, ClientRole clientRole = ClientRole.Primary) { ClientConfig config = new ClientConfig(clientRole); config.SetServerAddress(server); config.SetServerPort(port); config.SetLogWriter(LogWriter); this.SharingManager = SharingManager.Create(config); this.SharingManager.SetUserName(userName); this.viewerConnection = this.SharingManager.GetPairedConnection(); this.serverConnection = this.SharingManager.GetServerConnection(); this.SessionManager = this.SharingManager.GetSessionManager(); BeginPairing(); ViewerListener = new NetworkConnectionAdapter(); ViewerListener.ConnectedCallback += this.OnViewerConnected; ViewerListener.ConnectionFailedCallback += this.OnViewerConnectionFailed; ViewerListener.DisconnectedCallback += this.OnViewerDisconnected; viewerConnection.AddListener((byte)MessageID.StatusOnly, ViewerListener); ServerListener = new NetworkConnectionAdapter(); ServerListener.ConnectedCallback += this.OnSessionConnected; ServerListener.ConnectionFailedCallback += this.OnSessionConnectionFailed; ServerListener.DisconnectedCallback += this.OnSessionDisconnected; serverConnection.AddListener((byte)MessageID.StatusOnly, ServerListener); this.syncListener = new ConsoleSyncReporter(); this.rootObject = this.SharingManager.GetRootSyncObject(); this.rootObject.AddListener(this.syncListener); SessionManagerListener = new XToolsSessionManagerListener(this.LogWriter); this.SessionManager.AddListener(SessionManagerListener); networkMessageLoop = new Timer(new TimerCallback((a) => Update()), null, 0, 1000); }
public ChatItem(NavBarControl source, string userName, string displayName, ChatType chatType, ClientRole userType) { Name = "item_" + userName; Caption = displayName; switch (chatType) { case ChatType.PrivateChat: switch (userType) { case ClientRole.Teacher: case ClientRole.Assistant: SmallImage = Resource1.老师24; break; case ClientRole.Student: SmallImage = Resource1.学生24; break; default: break; } source.Groups[2].ItemLinks.Add(this); // this.paren = source.Groups[2]; break; case ChatType.GroupChat: SmallImage = Resource1.所有人24; source.Groups[0].ItemLinks.Add(this); // this.Group = source.Groups[0]; break; case ChatType.TeamChat: SmallImage = Resource1.群组24; source.Groups[1].ItemLinks.Add(this); // this.Group = source.Groups[1]; var childList = GlobalVariable.GetTeamMemberDisplayNames(userName); Caption = displayName + " 【" + childList.Count + "】"; Hint = string.Join("\r\n", childList); // this.ToolTipText = string.Join("\r\n", childList); break; default: break; } this.UserName = userName; this.DisplayName = displayName; this.ChatType = chatType; DefaultImg = SmallImage; // this.AppearanceHotTracked.BorderColor = System.Drawing.Color.Black; // this.AppearanceHotTracked.Options.UseBorderColor = true; source.Items.Add(this); }
private void CreateChatItem(ChatListItem ParentItem, string userName, string displayName, ChatType type, ClientRole userType) { this.DisplayName = displayName; switch (type) { case ChatType.PrivateChat: switch (userType) { case ClientRole.Teacher: case ClientRole.Assistant: this.HeadImage = Resource1.老师; break; case ClientRole.Student: this.HeadImage = Resource1.学生; break; default: break; } break; case ChatType.GroupChat: this.HeadImage = Resource1.所有人; break; case ChatType.TeamChat: this.HeadImage = Resource1.群聊; break; default: break; } // this.HeadRect = new System.Drawing.Rectangle(5, 33, 40, 40); this.ID = 1; this.IpAddress = null; // this.IsTwinkle = false; // this.IsTwinkleHide = false; // this.IsVip = false; this.NicName = ""; this.OwnerListItem = ParentItem; this.PersonalMsg = ""; // this.PlatformTypes = CCWin.SkinControl.PlatformType.PC; // this.QQShow = null; // this.Status = CCWin.SkinControl.ChatListSubItem.UserStatus.Online; this.Tag = userName; ParentItem.SubItems.Add(this); // this.TcpPort = 0; // this.UpdPort = 0; }
public virtual void SendTo(User user, ClientRole deviceRole, NetworkOutMessage msg) { SharingClientPINVOKE.NetworkConnection_SendTo__SWIG_4(swigCPtr, User.getCPtr(user), (int)deviceRole, NetworkOutMessage.getCPtr(msg)); }
public virtual void SendTo(User user, ClientRole deviceRole, NetworkOutMessage msg, MessagePriority priority, MessageReliability reliability) { SharingClientPINVOKE.NetworkConnection_SendTo__SWIG_2(swigCPtr, User.getCPtr(user), (int)deviceRole, NetworkOutMessage.getCPtr(msg), (int)priority, (int)reliability); }
private QuickPage Index(string companyId, TextShow companyName, ClientRole clientRole, TextShow contactText) { return(new QuickPage(Helper.Index(companyName, clientRole))); }
public ChatItem(ChatListPanel parent, string userName, string displayName, ChatType chatType, ClientRole userType) { GlobalVariable.GetOrCreateChatStore(userName, chatType); _parentPanel = parent; InitializeComponent(); this.Height = 24 + 5 * 2; this.BackColor = defaultBackColor; this.HorizontalScroll.Enabled = false; this.Cursor = Cursors.Hand; SetChatPanelHover(); this.MouseClick += ChatItem_MouseClick; Name = "item_" + userName; switch (chatType) { case ChatType.PrivateChat: switch (userType) { case ClientRole.Teacher: case ClientRole.Assistant: headIcon = Resource1.主机端24; break; case ClientRole.Student: headIcon = Resource1.客户端24; break; default: break; } break; case ChatType.GroupChat: headIcon = Resource1.所有人24; break; case ChatType.TeamChat: headIcon = Resource1.群组24; // var childList = GlobalVariable.GetTeamMemberDisplayNames(userName); this.ContextMenuStrip = contextMenuStrip1; // Caption = displayName + " 【" + childList.Count + "】"; // Hint = string.Join("\r\n", childList); // this.ToolTipText = string.Join("\r\n", childList); break; default: break; } this.UserName = userName; this.DisplayName = displayName; this.ChatType = chatType; }
public ClientRole GetRole() { ClientRole ret = (ClientRole)SharingClientPINVOKE.ClientConfig_GetRole(swigCPtr); return(ret); }
// private volatile static MyTcpClient _instance = null; // private static readonly object lockHelper = new object(); //public static MyTcpClient CreateInstance() //{ // if (_instance == null) // { // lock (lockHelper) // { // if (_instance == null) // _instance = new MyTcpClient(); // } // } // return _instance; //} #region 发送命令 public async Task Send_UserLogin(string userName, string nickName, string password, ClientRole clientRole) { // GetAudioName(); var loginInfo = new LoginInfo(); if (clientRole == ClientRole.Teacher || clientRole == ClientRole.Assistant) { loginInfo.username = nickName; loginInfo.nickname = "老师"; loginInfo.password = password; } else { loginInfo.username = userName; loginInfo.nickname = nickName; loginInfo.no = password; } loginInfo.clientRole = clientRole; loginInfo.clientStyle = ClientStyle.PC; SendMessage <LoginInfo> message = new SendMessage <LoginInfo>(); message.Action = (int)CommandType.UserLogin; message.Data = loginInfo; await SendMessage(message); //Task.Run(async () => //{ // await this.SendMessage(message); //}); }
public ClientConfig(ClientRole role) : this(SharingClientPINVOKE.new_ClientConfig((int)role), true) { }
public static void RaiseClientRoleAssigned(this IClientManager clientManager, string clientId, ClientRole role) { clientManager.Raise(_ => _.ClientRoleAssigned += null, clientManager, new ClientRoleAssignedArgs(clientId, role)); }
/// <summary> /// 用户登录 /// </summary> /// <param name="userName"></param> /// <param name="nickName"></param> /// <param name="password"></param> /// <param name="clientRole"></param> public void Send_UserLogin(string userName, string nickName, string password, ClientRole clientRole) { // GetAudioName(); var loginInfo = new LoginInfo(); if (clientRole == ClientRole.Teacher || clientRole == ClientRole.Assistant) { loginInfo.username = nickName; loginInfo.nickname = "老师"; loginInfo.password = password; } else { loginInfo.username = userName; loginInfo.nickname = nickName; loginInfo.no = password; } loginInfo.clientRole = clientRole; loginInfo.clientStyle = ClientStyle.PC; SendMessage(loginInfo, CommandType.UserLogin); }
private string GetClientAssigmentMessage(ClientRole role) { switch (role) { case ClientRole.PlayerX: return "You are X's."; case ClientRole.PlayerO: return "You are O's."; case ClientRole.Spectator: return "You are a spectator."; default: throw new InvalidOperationException(String.Format("There is no assignment message for role '{0}'.", role.ToString())); } }
//public void KillAllFFmpeg() //{ // CreateScreenInteract(); // _screenInteract.KillAllFFmpeg(); //} #region 发送命令 /// <summary> /// 用户登录 /// </summary> /// <param name="userName"></param> /// <param name="nickName"></param> /// <param name="password"></param> /// <param name="clientRole"></param> public void Send_UserLogin(string userName, string nickName, string password, ClientRole clientRole) { var loginInfo = new LoginInfo(); loginInfo.username = userName; loginInfo.nickname = nickName; loginInfo.no = password; loginInfo.clientRole = clientRole; loginInfo.clientStyle = ClientStyle.PC; SendMessage(loginInfo, CommandType.UserLogin); }
public ClientRoleAssignedArgs(string clientId, ClientRole role) { ClientId = clientId; Role = role; }