/// <summary> /// Send data through epic network. /// </summary> /// <param name="host">The person we want to send data to.</param> /// <param name="msgBuffer">The data we are sending.</param> /// <param name="channel">The channel we are going to send data on.</param> /// <returns></returns> private bool Send(ProductUserId host, byte[] msgBuffer, int channel) { bool sent = EpicManager.P2PInterface.SendPacket(new SendPacketOptions { AllowDelayedDelivery = true, Channel = (byte)channel, Data = msgBuffer, LocalUserId = EpicManager.AccountId.ProductUserId, Reliability = Options.Channels[channel], RemoteUserId = host, SocketId = SocketName }) == Result.Success; if (sent) { if (Transport.transportDebug) { DebugLogger.RegularDebugLog("[Client] - Packet sent successfully."); } } else { if (Transport.transportDebug) { DebugLogger.RegularDebugLog("[Client] - Packet failed to send."); } } return(sent); }
/// <summary> /// Receive the next packet for the local user, and information associated with this packet, if it exists. /// </summary> /// <param name="options">Information about who is requesting the size of their next packet, and how much data can be stored safely</param> /// <param name="outPeerId">The Remote User who sent data. Only set if there was a packet to receive.</param> /// <param name="outSocketId">The Socket ID of the data that was sent. Only set if there was a packet to receive.</param> /// <param name="outChannel">The channel the data was sent on. Only set if there was a packet to receive.</param> /// <param name="outData">Buffer to store the data being received. Must be at least <see cref="GetNextReceivedPacketSize" /> in length or data will be truncated</param> /// <param name="outBytesWritten">The amount of bytes written to OutData. Only set if there was a packet to receive.</param> /// <returns> /// <see cref="Result" />::<see cref="Result.Success" /> - If the packet was received successfully /// <see cref="Result" />::<see cref="Result.InvalidParameters" /> - If input was invalid /// <see cref="Result" />::<see cref="Result.NotFound" /> - If there are no packets available for the requesting user /// </returns> public Result ReceivePacket(ReceivePacketOptions options, out ProductUserId outPeerId, out SocketId outSocketId, out byte outChannel, out byte[] outData) { System.IntPtr optionsAddress = new System.IntPtr(); Helper.TryMarshalSet <ReceivePacketOptionsInternal, ReceivePacketOptions>(ref optionsAddress, options); var outPeerIdAddress = System.IntPtr.Zero; var outSocketIdInternal = Helper.GetDefault <SocketIdInternal>(); outChannel = Helper.GetDefault <byte>(); System.IntPtr outDataAddress = System.IntPtr.Zero; uint outBytesWritten = MaxPacketSize; Helper.TryMarshalAllocate(ref outDataAddress, outBytesWritten); var funcResult = EOS_P2P_ReceivePacket(InnerHandle, optionsAddress, ref outPeerIdAddress, ref outSocketIdInternal, ref outChannel, outDataAddress, ref outBytesWritten); Helper.TryMarshalDispose(ref optionsAddress); Helper.TryMarshalGet(outPeerIdAddress, out outPeerId); Helper.TryMarshalGet(outSocketIdInternal, out outSocketId); Helper.TryMarshalGet(outDataAddress, out outData, outBytesWritten); Helper.TryMarshalDispose(ref outDataAddress); return(funcResult); }
public EpicMessage(ProductUserId connectionId, int channel, InternalMessage eventType, byte[] data) { EventType = eventType; Data = data; ConnectionId = connectionId; Channel = channel; }
protected override void OnReceiveData(byte[] data, ProductUserId clientUserId, int channel) { if (ignoreAllMessages) { return; } if (epicToMirrorIds.TryGetValue(clientUserId, out ulong connectionId)) { transport.OnCommonDataReceived.Invoke(connectionId, data, channel); //OnReceivedData.Invoke(connectionId, data, channel); } else { SocketId socketId; epicToSocketIds.TryGetValue(clientUserId, out socketId); CloseP2PSessionWithUser(clientUserId, socketId); string productId; clientUserId.ToString(out productId); Debug.LogError("Data received from epic client thats not known " + productId); transport.OnCommonErrored.Invoke(0, new Exception("ERROR Unknown product ID")); } }
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; } }
/// <summary> /// ログイン /// </summary> /// <returns>タスク</returns> async UniTask _Login() { var auth = EOSComponent.auth; var con = EOSComponent.connect; var authRes = await auth.Login(Epic.OnlineServices.Auth.LoginCredentialType.Developer, $"localhost:{inptDevPort.text}", inptDevName.text); if (authRes == null) { return; } var token = auth.CopyUserAuthToken(authRes.LocalUserId); if (token == null) { return; } var conRes = await con.Login(token.AccessToken, Epic.OnlineServices.Connect.ExternalCredentialType.Epic); if (conRes == null) { return; } m_localUserId = conRes.LocalUserId; }
/// <summary> /// Connect clients async to mirror backend. /// </summary> /// <param name="uri">The address we want to connect to using steam ids.</param> /// <returns></returns> public override async UniTask <IConnection> ConnectAsync(Uri uri) { if (!EpicManager.Initialized) { if (Logger.logEnabled) { if (transportDebug) { DebugLogger.RegularDebugLog("Epic not initialized. Client could not be started."); } } return(null); } _epicOptions.ConnectionAddress = ProductUserId.FromString(uri.Host); _client = new Client(this, _epicOptions, false); _client.Error += (errorCode, message) => Error?.Invoke(errorCode, message); await _client.ConnectAsync(); return(_client); }
private void FetchEpicAccountId() { if (EOSSDKComponent.Initialized) { productUserId = EOSSDKComponent.localUserProductId; } }
private void OnConnectInterfaceLogin(Epic.OnlineServices.Connect.LoginCallbackInfo loginCallbackInfo) { if (loginCallbackInfo.ResultCode == Result.Success) { Debug.Log("Connect Interface Login succeeded"); string productIdString; Result result = loginCallbackInfo.LocalUserId.ToString(out productIdString); if (Result.Success == result) { Debug.Log("EOS User Product ID:" + productIdString); localUserProductIdString = productIdString; localUserProductId = loginCallbackInfo.LocalUserId; } initialized = true; isConnecting = false; } else { Debug.Log("Login returned " + loginCallbackInfo.ResultCode + "\nRetrying..."); EOS.GetConnectInterface().CreateUser(new Epic.OnlineServices.Connect.CreateUserOptions() { ContinuanceToken = loginCallbackInfo.ContinuanceToken }, null, (Epic.OnlineServices.Connect.CreateUserCallbackInfo cb) => { if (cb.ResultCode != Result.Success) { Debug.Log(cb.ResultCode); return; } localUserProductId = cb.LocalUserId; ConnectInterfaceLogin(); }); } }
/// <summary> /// Receive the next packet for the local user, and information associated with this packet, if it exists. /// </summary> /// <param name="options">Information about who is requesting the size of their next packet, and how much data can be stored safely</param> /// <param name="outPeerId">The Remote User who sent data. Only set if there was a packet to receive.</param> /// <param name="outSocketId">The Socket ID of the data that was sent. Only set if there was a packet to receive.</param> /// <param name="outChannel">The channel the data was sent on. Only set if there was a packet to receive.</param> /// <param name="outData">Buffer to store the data being received. Must be at least <see cref="GetNextReceivedPacketSize" /> in length or data will be truncated</param> /// <param name="outBytesWritten">The amount of bytes written to OutData. Only set if there was a packet to receive.</param> /// <returns> /// <see cref="Result" />::<see cref="Result.Success" /> - If the packet was received successfully /// <see cref="Result" />::<see cref="Result.InvalidParameters" /> - If input was invalid /// <see cref="Result" />::<see cref="Result.NotFound" /> - If there are no packets available for the requesting user /// </returns> public Result ReceivePacket(ReceivePacketOptions options, out ProductUserId outPeerId, out SocketId outSocketId, out byte outChannel, ref byte[] outData, out uint outBytesWritten) { var optionsInternal = Helper.CopyProperties <ReceivePacketOptionsInternal>(options); outPeerId = Helper.GetDefault <ProductUserId>(); var outPeerIdAddress = IntPtr.Zero; outSocketId = Helper.GetDefault <SocketId>(); var outSocketIdInternal = new SocketIdInternal(); outChannel = Helper.GetDefault <byte>(); outBytesWritten = Helper.GetDefault <uint>(); var funcResult = EOS_P2P_ReceivePacket(InnerHandle, ref optionsInternal, ref outPeerIdAddress, ref outSocketIdInternal, ref outChannel, outData, ref outBytesWritten); Helper.TryMarshalDispose(ref optionsInternal); Helper.TryMarshalGet(outPeerIdAddress, out outPeerId); outSocketId = Helper.CopyProperties <SocketId>(outSocketIdInternal); Helper.TryMarshalDispose(ref outSocketIdInternal); var funcResultReturn = Helper.GetDefault <Result>(); Helper.TryMarshalGet(funcResult, out funcResultReturn); return(funcResultReturn); }
/// <summary> /// Send an internal message through system. /// </summary> /// <param name="target">The steam person we are sending internal message to.</param> /// <param name="type">The type of <see cref="InternalMessage"/> we want to send.</param> internal bool SendInternal(ProductUserId target, InternalMessage type, SocketId socket) { Result sent = EpicManager.P2PInterface.SendPacket(new SendPacketOptions { AllowDelayedDelivery = true, Channel = (byte)Options.Channels.Length, Data = new[] { (byte)type }, LocalUserId = EpicManager.AccountId.ProductUserId, Reliability = PacketReliability.ReliableOrdered, RemoteUserId = target, SocketId = socket }); if (sent == Result.Success) { if (Transport.transportDebug) { DebugLogger.RegularDebugLog("[Client] - Packet sent successfully."); } } else { if (Transport.transportDebug) { DebugLogger.RegularDebugLog($"[Client] - Packet failed to send. Results: {sent}"); } } return(sent == Result.Success); }
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; } }
public void Set(GetFileMetadataCountOptions other) { if (other != null) { m_ApiVersion = PlayerDataStorageInterface.GetfilemetadatacountoptionsApiLatest; LocalUserId = other.LocalUserId; } }
public void Set(SessionSearchSetTargetUserIdOptions other) { if (other != null) { m_ApiVersion = SessionSearch.SessionsearchSettargetuseridApiLatest; TargetUserId = other.TargetUserId; } }
public void Set(GetProductUserExternalAccountCountOptions other) { if (other != null) { m_ApiVersion = ConnectInterface.GetproductuserexternalaccountcountApiLatest; TargetUserId = other.TargetUserId; } }
public void Set(GetUnlockedAchievementCountOptions other) { if (other != null) { m_ApiVersion = AchievementsInterface.GetunlockedachievementcountApiLatest; UserId = other.UserId; } }
/// <summary> /// Fetches the login status for an product user id. This product user id is considered logged in as long as the underlying access token has not expired. /// </summary> /// <param name="localUserId">the product user id of the user being queried</param> /// <returns> /// the enum value of a user's login status /// </returns> public LoginStatus GetLoginStatus(ProductUserId localUserId) { var funcResult = EOS_Connect_GetLoginStatus(InnerHandle, localUserId.InnerHandle); var funcResultReturn = Helper.GetDefault <LoginStatus>(); Helper.TryMarshalGet(funcResult, out funcResultReturn); return(funcResultReturn); }
public void Set(SessionSearchFindOptions other) { if (other != null) { m_ApiVersion = SessionSearch.SessionsearchFindApiLatest; LocalUserId = other.LocalUserId; } }
public void Set(DeleteCacheOptions other) { if (other != null) { m_ApiVersion = PlayerDataStorageInterface.DeletecacheoptionsApiLatest; LocalUserId = other.LocalUserId; } }
public void Set(QueryFileListOptions other) { if (other != null) { m_ApiVersion = PlayerDataStorageInterface.QueryfilelistoptionsApiLatest; LocalUserId = other.LocalUserId; } }
public void Set(UnlinkAccountOptions other) { if (other != null) { m_ApiVersion = ConnectInterface.UnlinkaccountApiLatest; LocalUserId = other.LocalUserId; } }
public void Set(LobbySearchFindOptions other) { if (other != null) { m_ApiVersion = LobbySearch.LobbysearchFindApiLatest; LocalUserId = other.LocalUserId; } }
public void Set(GetInviteCountOptions other) { if (other != null) { m_ApiVersion = SessionsInterface.GetinvitecountApiLatest; LocalUserId = other.LocalUserId; } }
public void Set(GetPlayerAchievementCountOptions other) { if (other != null) { m_ApiVersion = AchievementsInterface.GetplayerachievementcountApiLatest; UserId = other.UserId; } }
public void Set(QueryInvitesOptions other) { if (other != null) { m_ApiVersion = SessionsInterface.QueryinvitesApiLatest; LocalUserId = other.LocalUserId; } }
public void Set(GetStatCountOptions other) { if (other != null) { m_ApiVersion = StatsInterface.GetstatscountApiLatest; TargetUserId = other.TargetUserId; } }
public void Set(LobbyDetailsGetMemberAttributeCountOptions other) { if (other != null) { m_ApiVersion = LobbyDetails.LobbydetailsGetmemberattributecountApiLatest; TargetUserId = other.TargetUserId; } }
public void Set(GetPlayerSanctionCountOptions other) { if (other != null) { m_ApiVersion = SanctionsInterface.GetplayersanctioncountApiLatest; TargetUserId = other.TargetUserId; } }
internal void Set(AuthExpirationCallbackInfoInternal?other) { if (other != null) { ClientData = other.Value.ClientData; LocalUserId = other.Value.LocalUserId; } }
public void Set(QueryPlayerAchievementsOptions other) { if (other != null) { m_ApiVersion = AchievementsInterface.QueryplayerachievementsApiLatest; UserId = other.UserId; } }