protected override void OnReceiveInternalData(InternalMessages type, CSteamID clientSteamID) { switch (type) { case InternalMessages.ACCEPT_CONNECT: if (!Connected) { Connected = true; OnConnected.Invoke(); Debug.Log("Connection established."); } break; case InternalMessages.DISCONNECT: if (Connected) { Connected = false; Debug.Log("Disconnected."); OnDisconnected.Invoke(); } break; default: Debug.Log("Received unknown message type"); break; } }
protected override void OnReceiveInternalData(InternalMessages type, ProductUserId clientUserId) { switch (type) { case InternalMessages.CONNECT: if (epicToMirrorIds.Count >= maxConnections) { SendInternal(clientUserId, InternalMessages.DISCONNECT); return; } SendInternal(clientUserId, InternalMessages.ACCEPT_CONNECT); int connectionId = nextConnectionID++; epicToMirrorIds.Add(clientUserId, connectionId); OnConnected.Invoke(connectionId); Debug.Log($"Client with Product User ID {clientUserId} connected. Assigning connection id {connectionId}"); break; case InternalMessages.DISCONNECT: if (epicToMirrorIds.TryGetValue(clientUserId, out int connId)) { OnDisconnected.Invoke(connId); CloseP2PSessionWithUser(clientUserId); epicToMirrorIds.Remove(clientUserId); Debug.Log($"Client with Product User ID {clientUserId} disconnected."); } else { OnReceivedError.Invoke(-1, new Exception("ERROR Unknown Product User ID")); } break; default: Debug.Log("Received unknown message type"); break; } }
protected override void OnReceiveInternalData(InternalMessages type, ProductUserId clientUserId, SocketId socketId) { if (ignoreAllMessages) { return; } switch (type) { case InternalMessages.ACCEPT_CONNECT: Connected = true; OnConnected.Invoke(); Debug.Log("Connection established."); break; case InternalMessages.DISCONNECT: Connected = false; Debug.Log("Disconnected."); OnDisconnected.Invoke(); break; default: Debug.Log("Received unknown message type"); break; } }
protected override void OnReceiveInternalData(InternalMessages type, CSteamID clientSteamID) { switch (type) { case InternalMessages.CONNECT: if (steamToMirrorIds.Count >= maxConnections) { SendInternal(clientSteamID, InternalMessages.DISCONNECT); return; } SendInternal(clientSteamID, InternalMessages.ACCEPT_CONNECT); int connectionId = nextConnectionID++; steamToMirrorIds.Add(clientSteamID, connectionId); OnConnected.Invoke(connectionId); Debug.Log($"Client with SteamID {clientSteamID} connected. Assigning connection id {connectionId}"); break; case InternalMessages.DISCONNECT: if (steamToMirrorIds.TryGetValue(clientSteamID, out int connId)) { OnDisconnected.Invoke(connId); CloseP2PSessionWithUser(clientSteamID); steamToMirrorIds.Remove(clientSteamID); Debug.Log($"Client with SteamID {clientSteamID} disconnected."); } break; default: Debug.Log("Received unknown message type"); break; } }
protected void SendInternal(CSteamID target, InternalMessages type) { #if UNITY_SERVER SteamGameServerNetworking.SendP2PPacket(target, new byte[] { (byte)type }, 1, EP2PSend.k_EP2PSendReliable, internal_ch); #else SteamNetworking.SendP2PPacket(target, new byte[] { (byte)type }, 1, EP2PSend.k_EP2PSendReliable, internal_ch); #endif }
public CustomError UnRetire(Organisation org, long byUserId, string details = null) { if (org.Status != OrganisationStatuses.Retired) { return(InternalMessages.OrganisationRevertOnlyRetiredErrorMessage(org.OrganisationName, org.EmployerReference, org.Status.ToString())); } org.RevertToLastStatus(byUserId, details); return(null); }
public virtual CustomResult <Organisation> LoadInfoFromActiveEmployerIdentifier(string employerIdentifier) { CustomResult <Organisation> result = LoadInfoFromEmployerIdentifier(employerIdentifier); if (!result.Failed && !result.Result.IsSearchable()) { return(new CustomResult <Organisation>(InternalMessages.HttpGoneCausedByOrganisationBeingInactive(result.Result.Status))); } return(result); }
protected override void OnReceiveInternalData(InternalMessages type, ProductUserId clientUserId, SocketId socketId) { if (ignoreAllMessages) { return; } switch (type) { case InternalMessages.CONNECT: if (epicToMirrorIds.Count >= maxConnections) { Debug.LogError("Reached max connections"); //CloseP2PSessionWithUser(clientUserId, socketId); SendInternal(clientUserId, socketId, InternalMessages.DISCONNECT); return; } SendInternal(clientUserId, socketId, InternalMessages.ACCEPT_CONNECT); int connectionId = nextConnectionID++; epicToMirrorIds.Add(clientUserId, connectionId); epicToSocketIds.Add(clientUserId, socketId); Debug.LogError("Adding new connection with ID: " + connectionId); OnConnected.Invoke(connectionId); string clientUserIdString; clientUserId.ToString(out clientUserIdString); Debug.Log($"Client with Product User ID {clientUserIdString} connected. Assigning connection id {connectionId}"); break; case InternalMessages.DISCONNECT: if (epicToMirrorIds.TryGetValue(clientUserId, out int connId)) { OnDisconnected.Invoke(connId); //CloseP2PSessionWithUser(clientUserId, socketId); epicToMirrorIds.Remove(clientUserId); epicToSocketIds.Remove(clientUserId); Debug.LogError($"Client with Product User ID {clientUserId} disconnected."); } else { OnReceivedError.Invoke(-1, new Exception("ERROR Unknown Product User ID")); } break; default: Debug.Log("Received unknown message type"); break; } }
protected void SendInternal(ProductUserId target, SocketId socketId, InternalMessages type) { EOSSDKComponent.GetP2PInterface().SendPacket(new SendPacketOptions() { AllowDelayedDelivery = true, Channel = (byte)internal_ch, Data = new byte[] { (byte)type }, LocalUserId = EOSSDKComponent.LocalUserProductId, Reliability = PacketReliability.ReliableOrdered, RemoteUserId = target, SocketId = socketId }); }
private CustomResult <Organisation> SecurityCodeNotExpiredValidate(Organisation organisation) { CustomResult <Organisation> securityCodeNotExpiredValidationResult = null; if (organisation?.SecurityCodeExpiryDateTime != null && organisation.SecurityCodeExpiryDateTime < VirtualDateTime.Now) { securityCodeNotExpiredValidationResult = new CustomResult <Organisation>( InternalMessages.SecurityCodeCannotModifyAnAlreadyExpiredSecurityCodeErrorMessage(), organisation); } return(securityCodeNotExpiredValidationResult); }
private CustomResult <Organisation> SecurityCodeDateTimeInFutureValidate(Organisation organisation, DateTime securityCodeExpiryDateTime) { CustomResult <Organisation> futureValidationResult = null; if (securityCodeExpiryDateTime < VirtualDateTime.Now) { futureValidationResult = new CustomResult <Organisation>( InternalMessages.SecurityCodeMustExpireInFutureErrorMessage(), organisation); } return(futureValidationResult); }
public CustomResult <Organisation> GetOrganisationByEncryptedReturnId(string encryptedReturnId) { string decryptedReturnId = _encryptionHandler.DecryptAndDecode(encryptedReturnId); Return result = _submissionLogic.GetSubmissionByReturnId(decryptedReturnId.ToInt64()); if (result == null) { return(new CustomResult <Organisation>(InternalMessages.HttpNotFoundCausedByReturnIdNotInDatabase(encryptedReturnId))); } Organisation organisation = GetOrganisationById(result.OrganisationId); return(new CustomResult <Organisation>(organisation)); }
public async Task <CustomResult <Organisation> > GetOrganisationByEncryptedReturnIdAsync(string encryptedReturnId) { var decryptedReturnId = _sharedBusinessLogic.Obfuscator.DeObfuscate(encryptedReturnId); var result = await _submissionLogic.GetSubmissionByReturnIdAsync(decryptedReturnId.ToInt64()); if (result == null) { return(new CustomResult <Organisation>( InternalMessages.HttpNotFoundCausedByReturnIdNotInDatabase(encryptedReturnId))); } var organisation = GetOrganisationById(result.OrganisationId); return(new CustomResult <Organisation>(organisation)); }
public virtual async Task <CustomResult <OrganisationScope> > AddScopeAsync(Organisation organisation, ScopeStatuses newStatus, User currentUser, int snapshotYear, string comment, bool saveToDatabase) { snapshotYear = _sharedBusinessLogic.GetAccountingStartDate(organisation.SectorType, snapshotYear) .Year; var oldOrgScope = organisation.GetScopeOrThrow(snapshotYear); if (oldOrgScope.ScopeStatus == newStatus) { return(new CustomResult <OrganisationScope>( InternalMessages.SameScopesCannotBeUpdated(newStatus, oldOrgScope.ScopeStatus, snapshotYear))); } // When Organisation is Found Then Save New Scope Record With New Status var newScope = new OrganisationScope { OrganisationId = oldOrgScope.OrganisationId, Organisation = organisation, /* Updated by the current user */ ContactEmailAddress = currentUser.EmailAddress, ContactFirstname = currentUser.Firstname, ContactLastname = currentUser.Lastname, ReadGuidance = oldOrgScope.ReadGuidance, Reason = !string.IsNullOrEmpty(comment) ? comment : oldOrgScope.Reason, ScopeStatus = newStatus, ScopeStatusDate = VirtualDateTime.Now, StatusDetails = _sharedBusinessLogic.AuthorisationBusinessLogic.IsAdministrator(currentUser) ? "Changed by Admin" : null, RegisterStatus = oldOrgScope.RegisterStatus, RegisterStatusDate = oldOrgScope.RegisterStatusDate, // carry the snapshot date over SnapshotDate = oldOrgScope.SnapshotDate }; await SaveScopeAsync(organisation, saveToDatabase, newScope); return(new CustomResult <OrganisationScope>(newScope)); }
public CustomResult <Organisation> LoadInfoFromEmployerIdentifier(string employerIdentifier) { int organisationId = _obfuscator.DeObfuscate(employerIdentifier); if (organisationId == 0) { return(new CustomResult <Organisation>(InternalMessages.HttpBadRequestCausedByInvalidEmployerIdentifier(employerIdentifier))); } Organisation organisation = GetOrganisationById(organisationId); if (organisation == null) { return(new CustomResult <Organisation>(InternalMessages.HttpNotFoundCausedByOrganisationIdNotInDatabase(employerIdentifier))); } return(new CustomResult <Organisation>(organisation)); }
protected override void OnReceiveInternalData(InternalMessages type, ProductUserId clientUserId, SocketId socketId, byte[] payload = null) { if (ignoreAllMessages) { return; } switch (type) { case InternalMessages.ACCEPT_CONNECT: Connected = true; transport.OnCommonConnected.Invoke(transport.ServerClientId); //OnConnected.Invoke(); Debug.Log("Connection established."); break; case InternalMessages.DISCONNECT: Connected = false; Debug.Log("Disconnected."); transport.OnCommonDisconnected.Invoke(transport.ServerClientId); //OnDisconnected.Invoke(); break; case InternalMessages.PING: if (payload[1] == 0) { payload[1] = 0xff; SendInternal(clientUserId, socketId, payload); } else { float sendTime = BitConverter.ToSingle(payload, 2); currentPing = (ulong)((Time.realtimeSinceStartup - sendTime) / 1000.0f); } break; default: Debug.Log("Received unknown message type"); break; } }
public CustomResult <Organisation> CreateSecurityCode(Organisation organisation, DateTime securityCodeExpiryDateTime) { if (!(organisation.IsActive() | organisation.IsPending())) { return(new CustomResult <Organisation>( InternalMessages.SecurityCodeCreateIsOnlyAllowedToNonRetiredOrgsErrorMessage( organisation.OrganisationName, organisation.EmployerReference, organisation.Status.ToString()), organisation)); } return(SecurityCodeGenericMethod( organisation, securityCodeExpiryDateTime, null, SecurityCodeDateTimeInFutureValidate, SetOrganisationSecurityCode)); }
protected override void OnReceiveInternalData(InternalMessages type, SteamId clientSteamID) { switch (type) { case InternalMessages.CONNECT: if (steamToMirrorIds.Count >= maxConnections) { SendInternal(clientSteamID, InternalMessages.DISCONNECT); return; } SendInternal(clientSteamID, InternalMessages.ACCEPT_CONNECT); int connectionId = nextConnectionID++; steamToMirrorIds.Add(clientSteamID, connectionId); OnConnected?.Invoke(connectionId); Debug.Log($"Client with SteamID {clientSteamID} connected. Assigning connection id {connectionId}"); break; case InternalMessages.DISCONNECT: if (steamToMirrorIds.Contains(clientSteamID)) { OnDisconnected?.Invoke(steamToMirrorIds[clientSteamID]); steamToMirrorIds.Remove(clientSteamID); CloseP2PSessionWithUser(clientSteamID); Debug.Log($"Client with SteamID {clientSteamID} disconnected."); } else { OnReceivedError?.Invoke(-1, new Exception("ERROR Unknown SteamID")); } break; default: Debug.Log("Received unknown message type"); break; } }
public CustomResult <Return> GetSubmissionByOrganisationAndYear(Organisation organisation, int year) { IEnumerable <Return> reports = GetAllSubmissionsByOrganisationIdAndSnapshotYear(organisation.OrganisationId, year); if (!reports.Any()) { return(new CustomResult <Return>( InternalMessages.HttpNotFoundCausedByOrganisationReturnNotInDatabase(organisation.GetEncryptedId(), year))); } Return result = reports.OrderByDescending(r => r.Status == ReturnStatuses.Submitted) .ThenByDescending(r => r.StatusDate) .FirstOrDefault(); if (!result.IsSubmitted()) { return(new CustomResult <Return>( InternalMessages.HttpGoneCausedByReportNotHavingBeenSubmitted(result.AccountingDate.Year, result.Status.ToString()))); } return(new CustomResult <Return>(result)); }
protected override void OnReceiveInternalData(InternalMessages type, ProductUserId clientUserId, SocketId socketId, byte[] payload = null) { if (ignoreAllMessages) { return; } switch (type) { case InternalMessages.CONNECT: if (epicToMirrorIds.Count >= maxConnections) { Debug.LogError("Reached max connections"); //CloseP2PSessionWithUser(clientUserId, socketId); SendInternal(clientUserId, socketId, InternalMessages.DISCONNECT); return; } SendInternal(clientUserId, socketId, InternalMessages.ACCEPT_CONNECT); ulong connectionId = nextConnectionID++; epicToMirrorIds.Add(clientUserId, connectionId); epicToSocketIds.Add(clientUserId, socketId); transport.OnCommonConnected.Invoke(connectionId); //OnConnected.Invoke(connectionId); string clientUserIdString; clientUserId.ToString(out clientUserIdString); Debug.Log($"Client with Product User ID {clientUserIdString} connected. Assigning connection id {connectionId}"); break; case InternalMessages.DISCONNECT: if (epicToMirrorIds.TryGetValue(clientUserId, out ulong connId)) { transport.OnCommonDisconnected.Invoke(connId); //OnDisconnected.Invoke(connId); //CloseP2PSessionWithUser(clientUserId, socketId); epicToMirrorIds.Remove(clientUserId); epicToSocketIds.Remove(clientUserId); clientUserId.ToString(out string clientUserIdstr); Debug.Log($"Client with Product User ID {clientUserIdstr} disconnected."); } else { transport.OnCommonErrored.Invoke(0, new Exception("ERROR Unknown Product User ID")); } break; case InternalMessages.PING: if (payload[1] == 0) { payload[1] = 0xff; SendInternal(clientUserId, socketId, payload); } else { float sendTime = BitConverter.ToSingle(payload, 2); pings[epicToMirrorIds[clientUserId]] = (ulong)((Time.realtimeSinceStartup - sendTime) / 1000.0f); } break; default: Debug.Log("Received unknown message type"); break; } }
protected abstract void OnReceiveInternalData(InternalMessages type, ProductUserId clientUserID, SocketId socketId, byte[] payload = null);
protected void SendInternal(CSteamID target, InternalMessages type) => SteamNetworking.SendP2PPacket(target, new byte[] { (byte)type }, 1, EP2PSend.k_EP2PSendReliable, internal_ch);
protected abstract void OnReceiveInternalData(InternalMessages type, CSteamID clientSteamID);
protected void SendInternal(SteamId target, InternalMessages type) => SteamNetworking.SendP2PPacket(target, new byte[] { (byte)type }, 1, internal_ch, P2PSend.Reliable);
protected bool SendInternal(SteamId target, InternalMessages type) => SteamNetworking.SendP2PPacket(target, new byte[] { (byte)type }, 1, internal_ch);
protected abstract void OnReceiveInternalData(InternalMessages type, ProductUserId clientUserID, SocketId socketId);