Skip to content

Commit

Permalink
Merge pull request #51 from skeyll/dev0.6.3
Browse files Browse the repository at this point in the history
Fix: to get no args packet.
  • Loading branch information
skeyll committed Jun 12, 2024
2 parents f93df19 + 6928159 commit c6ed19e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions SynicSugar/Assets/SynicSugar/Runtime/p2p/EOSp2p.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ public static class EOSp2p {
/// <param name="byteArray"></param>
/// <returns></returns>
internal static string ByteArrayToHexString(byte[] byteArray) {
if(byteArray == null){
return string.Empty;
}
System.Text.StringBuilder hex = new System.Text.StringBuilder(byteArray.Length * 2);
foreach (byte b in byteArray) {
hex.AppendFormat("{0:x2}", b);
Expand All @@ -497,6 +500,9 @@ public static class EOSp2p {
/// <param name="byteArray"></param>
/// <returns></returns>
internal static string ByteArrayToHexString(ArraySegment<byte> byteArray){
if(byteArray.Count == 0){
return string.Empty;
}
System.Text.StringBuilder hex = new System.Text.StringBuilder(byteArray.Count * 2);
for (int i = byteArray.Offset; i < byteArray.Offset + byteArray.Count; i++){
hex.AppendFormat("{0:x2}", byteArray.Array[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public class p2pConnectorForOtherAssembly : MonoBehaviour {
/// To get packets
/// </summary>
GetNextReceivedPacketSizeOptions standardPacketSizeOptions, synicPacketSizeOptions;
uint nextPacketSizeBytes = 0;


#region Pause Session
Expand Down Expand Up @@ -211,8 +210,8 @@ public class p2pConnectorForOtherAssembly : MonoBehaviour {
/// Use this from hub not to call some methods in Main-Assembly from SynicSugar.dll.
/// </summary>
public bool GetPacketFromBuffer(ref byte ch, ref string id, ref ArraySegment<byte> payload){
P2PHandle.GetNextReceivedPacketSize(ref standardPacketSizeOptions, out nextPacketSizeBytes);
if(nextPacketSizeBytes == 0){
ResultE existPacket = P2PHandle.GetNextReceivedPacketSize(ref standardPacketSizeOptions, out uint nextPacketSizeBytes);
if(existPacket != ResultE.Success){
return false;
}
//Set options
Expand Down Expand Up @@ -246,8 +245,8 @@ public class p2pConnectorForOtherAssembly : MonoBehaviour {
/// Use this from ConenctHub not to call some methods in Main-Assembly from SynicSugar.dll.
/// </summary>
public bool GetSynicPacketFromBuffer(ref byte ch, ref string id, ref ArraySegment<byte> payload){
P2PHandle.GetNextReceivedPacketSize(ref synicPacketSizeOptions, out nextPacketSizeBytes);
if(nextPacketSizeBytes == 0){
ResultE existPacket = P2PHandle.GetNextReceivedPacketSize(ref synicPacketSizeOptions, out uint nextPacketSizeBytes);
if(existPacket != ResultE.Success){
return false;
}
//Set options
Expand Down

0 comments on commit c6ed19e

Please sign in to comment.