private void AcceptUser(ConnectionOperation user) { RMPPeer client = user.peer; // 스팀 인증이 끝나기 전에 접속 종료한 경우 if (client.Status != RMPPeer.PeerStatus.Connected) { Debug.LogWarning("User already disconnected while authorizing."); Server.Auth.EndSession(user.steamId); return; } var steamId = user.steamId; // 서버 프로그램은 직접 전달받는 것 외에는 유저의 정보를 알 방법이 없다. var username = user.username; var steamuser = new SteamUser(client, steamId, username); Users.Add(steamuser); Debug.Log(string.Format("Steam user connected. : {0}", username)); // accept 알림 _view.RPC(client, "clRPC_ConnectionAccepted"); OnSteamUserJoin.Invoke(steamuser); }
private void ProcessConnection() { // 클라이언트 접속, 퇴장의 순서와 atomic한 연산을 보장하기 위한 큐잉처리 if (NetworkService.IsOnline && NetworkService.IsServer) { if (_waitingUser == null && _operationQueue.Count > 0) { ConnectionOperation args = _operationQueue.Dequeue(); if (Server == null) { return; } switch (args.type) { case ConnectionOperationType.Connecting: UserAuth(args); break; case ConnectionOperationType.Disconnecting: DisposeUser(args); break; } } } }
private void _OnClientDisconnect(RMPPeer client) { // 다른 유저의 접속 처리 도중에 사라지면 안되기 때문에 atomic한 연산이 보장되어야 한다. ConnectionOperation disconnect = new ConnectionOperation(); disconnect.type = ConnectionOperationType.Disconnecting; disconnect.peer = client; _operationQueue.Enqueue(disconnect); }
public async Task CancelAllOperationsAsync( ) { if (_connection != null) { await _connection.CancelAsync(); _connection = null; } }
/// <summary> /// Operate for each requested ConnectionOperation /// </summary> /// <param name="op">ConnectionOperation</param> public void Operate(ConnectionOperation op) { try { switch (op) { // Show the current connected network case ConnectionOperation.CURRENT: CurrentConnection(); break; // Show the current Wi-Fi State case ConnectionOperation.WIFISTATE: WiFiState(); break; // Show the current Cellular state case ConnectionOperation.CELLULARSTATE: CellularState(); break; // Show the IPv4 address and the IPv6 address of the current connection case ConnectionOperation.IPADDRESS: IPAddress(); break; // Show the MAC address of Wi-Fi case ConnectionOperation.WIFIMACADDRESS: WiFiMACAddress(); break; // Show the proxy address case ConnectionOperation.PROXYADDRESS: ProxyAddress(); break; // Show the connection profiles case ConnectionOperation.PROFILELIST: ProfileList(); break; } } // C# API throws NotSupportedException if the API is not supported catch (NotSupportedException) { result.Text = "The operation is not supported on this device"; } catch (Exception e) { result.Text = e.ToString(); } }
private void svRPC_HandShake(string version, byte[] steamTicketData, ulong steamId, string username) { Debug.Log(string.Format("Steam auth ticket received. : {0}", username)); ConnectionOperation req = new ConnectionOperation(); req.type = ConnectionOperationType.Connecting; req.peer = _view.MessageSender; req.version = version; req.steamTicketData = steamTicketData; req.steamId = steamId; req.username = username; _operationQueue.Enqueue(req); }
private async Task CheckConnectionAsync() { if (_connection == null) { _connection = new ConnectionOperation(); _connection.Token.StateChanged += (s, e) => { if (e == OperationState.Faulted || e == OperationState.Canceled) { _connection = null; } }; await _connection.ExecuteAsync(); } }
private void UserAuth(ConnectionOperation user) { string version = user.version; RMPPeer client = user.peer; if (client.Status != RMPPeer.PeerStatus.Connected) { Debug.LogWarning("User already disconnected quickly before Steam Auth started."); return; } // 인원수 if (Users.Count >= Config.MaxPlayers) { string msg = "Server is full. (" + Users.Count + "/" + Config.MaxPlayers + ")"; RejectUser(client, msg); return; } // 버전 if (!version.Equals(Config.Version)) { string msg = "Version mismatch. Client: " + version + ", Server: " + Config.Version; RejectUser(client, msg); return; } // 스팀인증 var ticketData = user.steamTicketData; var steamId = user.steamId; var username = user.username; Debug.Log(string.Format("Authorizing steam user. : {0}", username)); if (Server.Auth.StartSession(ticketData, steamId)) { // 이후의 처리는 OnAuthChange 에서 user.steamId = steamId; SetServerAuthWaitingStatus(user); } else { string msg = "Failed to start steam auth session."; RejectUser(client, msg); return; } }
/// <summary> /// Constructor /// </summary> /// <param name="op">ConnectionOperation</param> public ConnectionResultPage(ConnectionOperation op) { result = CreateLabel(); // Create a Layout Content = new StackLayout { Children = { result, } }; connection = DependencyService.Get <IConnection>(); operation = op; Operate(op); }
private void DisposeUser(ConnectionOperation user) { var steamuser = Users.Find(u => u.Peer == user.peer); if (steamuser == null) { Debug.LogError("Disconnection event invoked, but steam user not found."); return; } Debug.Log(string.Format("Closing steam session. : {0}", steamuser.SteamId)); Server.Auth.EndSession(steamuser.SteamId); Users.Remove(steamuser); Debug.Log(string.Format("Steam user disconnected. : {0}", steamuser.Username)); OnSteamUserExit.Invoke(steamuser); }
/// <summary> /// Update the navigation property operations in connections /// <param name="body"></param> /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param> /// </summary> public RequestInformation CreatePatchRequestInformation(ConnectionOperation body, Action <ConnectionOperationItemRequestBuilderPatchRequestConfiguration> requestConfiguration = default) { _ = body ?? throw new ArgumentNullException(nameof(body)); var requestInfo = new RequestInformation { HttpMethod = Method.PATCH, UrlTemplate = UrlTemplate, PathParameters = PathParameters, }; requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body); if (requestConfiguration != null) { var requestConfig = new ConnectionOperationItemRequestBuilderPatchRequestConfiguration(); requestConfiguration.Invoke(requestConfig); requestInfo.AddRequestOptions(requestConfig.Options); requestInfo.AddHeaders(requestConfig.Headers); } return(requestInfo); }
private void OnAuthChange(ulong steamId, ulong ownerId, ServerAuth.Status status) { ConnectionOperation waitingUser = _waitingUser; // 인증 진행중인 유저에 대한 이벤트일 때 if (waitingUser != null && steamId == waitingUser.steamId) { // 인증 대기 목록에서 제거 ResetServerAuthWaitingStatus(); switch (status) { case ServerAuth.Status.OK: AcceptUser(waitingUser); break; case ServerAuth.Status.AuthTicketCanceled: Debug.LogWarning("Auth ticket canceled while doing user auth."); break; default: var message = string.Format("Steam auth failed. ({0}): {1}", waitingUser.username, status.ToString()); RejectUser(waitingUser.peer, message); break; } } else { switch (status) { case ServerAuth.Status.AuthTicketCanceled: Debug.Log("Auth ticket canceled. (" + steamId + ")"); break; default: Debug.Log("Steam auth changed. (" + steamId + ")"); break; } } }
private void ResetServerAuthWaitingStatus() { _waitingUser = null; StopCoroutine(timeout); timeout = null; }
private void SetServerAuthWaitingStatus(ConnectionOperation args) { _waitingUser = args; timeout = StartCoroutine(UserAuthTimeout()); }
private void ReadConnections(EmberReader reader) { reader.AssertInnerNumber(GlowConnectionCollection.InnerNumber); while (reader.Read() && (reader.InnerNumber != InnerNumber.EndContainer)) { switch (reader.GetContextSpecificOuterNumber()) { case GlowConnectionCollection.Connection.OuterNumber: reader.AssertInnerNumber(GlowConnection.InnerNumber); int? target = null; int[] connectedSources = new int[0]; ConnectionOperation operation = ConnectionOperation.Absolute; ConnectionDisposition disposition = ConnectionDisposition.Tally; while (reader.Read() && (reader.InnerNumber != InnerNumber.EndContainer)) { switch (reader.GetContextSpecificOuterNumber()) { case GlowConnection.Target.OuterNumber: target = this.ReadInt(reader, GlowConnection.Target.Name); break; case GlowConnection.Sources.OuterNumber: connectedSources = reader.AssertAndReadContentsAsInt32Array(); break; case GlowConnection.Operation.OuterNumber: operation = this.ReadEnum <ConnectionOperation>(reader, GlowConnection.Operation.Name); break; case GlowConnection.Disposition.OuterNumber: disposition = this.ReadEnum <ConnectionDisposition>(reader, GlowConnection.Disposition.Name); break; default: reader.Skip(); break; } } if (target.HasValue && (disposition != ConnectionDisposition.Pending) && !this.HasChanges) { var existingConnectedSources = this.Connections[target.Value]; switch (operation) { case ConnectionOperation.Absolute: Insert(existingConnectedSources, connectedSources, true); break; case ConnectionOperation.Connect: Insert(existingConnectedSources, connectedSources, false); break; case ConnectionOperation.Disconnect: foreach (var source in connectedSources) { existingConnectedSources.Remove(source); } break; } } break; default: reader.Skip(); break; } } }