Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .idea/.idea.EpicOnlineTransport.dir/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/.idea.EpicOnlineTransport.dir/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.EpicOnlineTransport.dir/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.EpicOnlineTransport.dir/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Mirror.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Mirror/Runtime.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Mirror/Runtime/Transport.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Mirror/Runtime/Transport/EpicOnlineTransport.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions Mirror/Runtime/Transport/EpicOnlineTransport/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,24 @@ protected override void OnReceiveData(byte[] data, ProductUserId clientUserId, i
OnReceivedData.Invoke(data, channel);
}

protected override void OnNewConnection(OnIncomingConnectionRequestInfo result) {
protected override void OnNewConnection(ref OnIncomingConnectionRequestInfo result) {
if (ignoreAllMessages) {
return;
}

if (deadSockets.Contains(result.SocketId.SocketName)) {
if (deadSockets.Contains(result.SocketId?.SocketName)) {
Debug.LogError("Received incoming connection request from dead socket");
return;
}

if (hostProductId == result.RemoteUserId) {
var acceptConnectionOptions = new AcceptConnectionOptions() {
LocalUserId = EOSSDKComponent.LocalUserProductId,
RemoteUserId = result.RemoteUserId,
SocketId = result.SocketId
};
EOSSDKComponent.GetP2PInterface().AcceptConnection(
new AcceptConnectionOptions() {
LocalUserId = EOSSDKComponent.LocalUserProductId,
RemoteUserId = result.RemoteUserId,
SocketId = result.SocketId
});
ref acceptConnectionOptions);
} else {
Debug.LogError("P2P Acceptance Request from unknown host ID.");
}
Expand Down
87 changes: 62 additions & 25 deletions Mirror/Runtime/Transport/EpicOnlineTransport/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ protected Common(EosTransport transport) {
OnIncomingConnectionRequest += OnNewConnection;
OnRemoteConnectionClosed += OnConnectFail;

incomingNotificationId = EOSSDKComponent.GetP2PInterface().AddNotifyPeerConnectionRequest(addNotifyPeerConnectionRequestOptions,
incomingNotificationId = EOSSDKComponent.GetP2PInterface().AddNotifyPeerConnectionRequest(ref addNotifyPeerConnectionRequestOptions,
null, OnIncomingConnectionRequest);

AddNotifyPeerConnectionClosedOptions addNotifyPeerConnectionClosedOptions = new AddNotifyPeerConnectionClosedOptions();
addNotifyPeerConnectionClosedOptions.LocalUserId = EOSSDKComponent.LocalUserProductId;
addNotifyPeerConnectionClosedOptions.SocketId = null;

outgoingNotificationId = EOSSDKComponent.GetP2PInterface().AddNotifyPeerConnectionClosed(addNotifyPeerConnectionClosedOptions,
outgoingNotificationId = EOSSDKComponent.GetP2PInterface().AddNotifyPeerConnectionClosed(ref addNotifyPeerConnectionClosedOptions,
null, OnRemoteConnectionClosed);

if (outgoingNotificationId == 0 || incomingNotificationId == 0) {
Expand All @@ -75,9 +75,9 @@ protected void Dispose() {
transport.ResetIgnoreMessagesAtStartUpTimer();
}

protected abstract void OnNewConnection(OnIncomingConnectionRequestInfo result);
protected abstract void OnNewConnection(ref OnIncomingConnectionRequestInfo result);

private void OnConnectFail(OnRemoteConnectionClosedInfo result) {
private void OnConnectFail(ref OnRemoteConnectionClosedInfo result) {
if (ignoreAllMessages) {
return;
}
Expand All @@ -86,66 +86,103 @@ private void OnConnectFail(OnRemoteConnectionClosedInfo result) {

switch (result.Reason) {
case ConnectionClosedReason.ClosedByLocalUser:
throw new Exception("Connection cLosed: The Connection was gracecfully closed by the local user.");
Debug.Log("Connection closed: The Connection was gracefully closed by the local user.");
break;
case ConnectionClosedReason.ClosedByPeer:
throw new Exception("Connection closed: The connection was gracefully closed by remote user.");
Debug.Log("Connection closed: The connection was gracefully closed by remote user.");
break;
case ConnectionClosedReason.ConnectionClosed:
throw new Exception("Connection closed: The connection was unexpectedly closed.");
Debug.LogWarning("Connection closed: The connection was unexpectedly closed.");
break;
case ConnectionClosedReason.ConnectionFailed:
throw new Exception("Connection failed: Failled to establish connection.");
Debug.LogError("Connection failed: Failed to establish connection.");
break;
case ConnectionClosedReason.InvalidData:
throw new Exception("Connection failed: The remote user sent us invalid data..");
Debug.LogError("Connection failed: The remote user sent us invalid data..");
break;
case ConnectionClosedReason.InvalidMessage:
throw new Exception("Connection failed: The remote user sent us an invalid message.");
Debug.LogError("Connection failed: The remote user sent us an invalid message.");
break;
case ConnectionClosedReason.NegotiationFailed:
throw new Exception("Connection failed: Negotiation failed.");
Debug.LogError("Connection failed: Negotiation failed.");
break;
case ConnectionClosedReason.TimedOut:
throw new Exception("Connection failed: Timeout.");
Debug.LogError("Connection failed: Timeout.");
break;
case ConnectionClosedReason.TooManyConnections:
throw new Exception("Connection failed: Too many connections.");
Debug.LogError("Connection failed: Too many connections.");
break;
case ConnectionClosedReason.UnexpectedError:
throw new Exception("Unexpected Error, connection will be closed");
Debug.LogError("Unexpected Error, connection will be closed");
break;
case ConnectionClosedReason.Unknown:
default:
throw new Exception("Unknown Error, connection has been closed.");
Debug.LogError("Unknown Error, connection has been closed.");
break;
}
}

protected void SendInternal(ProductUserId target, SocketId socketId, InternalMessages type) {
EOSSDKComponent.GetP2PInterface().SendPacket(new SendPacketOptions() {
var sendPacketOptions = new SendPacketOptions() {
AllowDelayedDelivery = true,
Channel = (byte) internal_ch,
Data = new byte[] { (byte) type },
Channel = (byte)internal_ch,
Data = new ArraySegment<byte>(new byte[] { (byte)type }),
LocalUserId = EOSSDKComponent.LocalUserProductId,
Reliability = PacketReliability.ReliableOrdered,
RemoteUserId = target,
SocketId = socketId
});
};
EOSSDKComponent.GetP2PInterface().SendPacket(ref sendPacketOptions);
}


protected void Send(ProductUserId host, SocketId socketId, byte[] msgBuffer, byte channel) {
Result result = EOSSDKComponent.GetP2PInterface().SendPacket(new SendPacketOptions() {
var sendPacketOptions = new SendPacketOptions() {
AllowDelayedDelivery = true,
Channel = channel,
Data = msgBuffer,
Data = new ArraySegment<byte>(msgBuffer),
LocalUserId = EOSSDKComponent.LocalUserProductId,
Reliability = channels[channel],
RemoteUserId = host,
SocketId = socketId
});
};
Result result = EOSSDKComponent.GetP2PInterface().SendPacket(ref sendPacketOptions);

if(result != Result.Success) {
Debug.LogError("Send failed " + result);
}
}

private bool Receive(out ProductUserId clientProductUserId, out SocketId socketId, out byte[] receiveBuffer, byte channel) {
Result result = EOSSDKComponent.GetP2PInterface().ReceivePacket(new ReceivePacketOptions() {
var receivePacketOptions = new ReceivePacketOptions() {
LocalUserId = EOSSDKComponent.LocalUserProductId,
MaxDataSizeBytes = P2PInterface.MaxPacketSize,
RequestedChannel = channel
}, out clientProductUserId, out socketId, out channel, out receiveBuffer);
};

var getNextReceivedPacketSizeOptions = new GetNextReceivedPacketSizeOptions() {
LocalUserId = EOSSDKComponent.LocalUserProductId,
RequestedChannel = channel
};
Result getPacketSizeResult = EOSSDKComponent.GetP2PInterface()
.GetNextReceivedPacketSize(ref getNextReceivedPacketSizeOptions, out var packetSize);

if (getPacketSizeResult != Result.Success) {
receiveBuffer = null;
clientProductUserId = null;
socketId = default;
return false;
}

uint bytesWritten = 0;
receiveBuffer = new byte[packetSize];
Result result = EOSSDKComponent.GetP2PInterface().ReceivePacket(
ref receivePacketOptions,
out clientProductUserId,
out socketId,
out channel,
new ArraySegment<byte>(receiveBuffer),
out bytesWritten);

if (result == Result.Success) {
return true;
Expand All @@ -157,7 +194,7 @@ private bool Receive(out ProductUserId clientProductUserId, out SocketId socketI
}

protected virtual void CloseP2PSessionWithUser(ProductUserId clientUserID, SocketId socketId) {
if (socketId == null) {
if (socketId.Equals(default(SocketId))) {
Debug.LogWarning("Socket ID == null | " + ignoreAllMessages);
return;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Loading