Skip to content

Commit

Permalink
Fix logs. Added SendUnconnected method with NetDataWriter argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
RevenantX committed Jun 10, 2016
1 parent 2008465 commit e6c088e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
11 changes: 11 additions & 0 deletions LiteNetLib/NetBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ public bool SendUnconnectedMessage(byte[] message, NetEndPoint remoteEndPoint)
return SendUnconnectedMessage(message, 0, message.Length, remoteEndPoint);
}

/// <summary>
/// Send message without connection
/// </summary>
/// <param name="writer">Data serializer</param>
/// <param name="remoteEndPoint">Packet destination</param>
/// <returns>Operation result</returns>
public bool SendUnconnectedMessage(NetDataWriter writer, NetEndPoint remoteEndPoint)
{
return SendUnconnectedMessage(writer.Data, 0, writer.Length, remoteEndPoint);
}

/// <summary>
/// Send message without connection
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion LiteNetLib/NetSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public int ReceiveFrom(ref byte[] data, ref NetEndPoint remoteEndPoint, ref int
}

//All ok!
NetUtils.DebugWriteError("[R]Recieved data from {0}, result: {1}", remoteEndPoint.ToString(), result);
NetUtils.DebugWrite(ConsoleColor.Blue, "[R]Recieved data from {0}, result: {1}", remoteEndPoint.ToString(), result);

//Assign data
data = _receiveBuffer;
Expand Down
13 changes: 9 additions & 4 deletions LiteNetLib/NetUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ public static string GetLocalIp(ConnectionAddressType connectionAddressType)

private static readonly object DebugLogLock = new object();

[Conditional("DEBUG_MESSAGES")]
internal static void DebugWrite(ConsoleColor color, string str, params object[] args)
private static void DebugWriteLogic(ConsoleColor color, string str, params object[] args)
{
lock (DebugLogLock)
{
Expand All @@ -133,16 +132,22 @@ internal static void DebugWrite(ConsoleColor color, string str, params object[]
}
}

[Conditional("DEBUG_MESSAGES")]
internal static void DebugWrite(ConsoleColor color, string str, params object[] args)
{
DebugWriteLogic(color, str, args);
}

[Conditional("DEBUG_MESSAGES"), Conditional("DEBUG")]
internal static void DebugWriteForce(ConsoleColor color, string str, params object[] args)
{
DebugWrite(color, str, args);
DebugWriteLogic(color, str, args);
}

[Conditional("DEBUG_MESSAGES"), Conditional("DEBUG")]
internal static void DebugWriteError(string str, params object[] args)
{
DebugWrite(ConsoleColor.Red, str, args);
DebugWriteLogic(ConsoleColor.Red, str, args);
}
}
}

0 comments on commit e6c088e

Please sign in to comment.