[ADD] added message received ok
This commit is contained in:
@@ -159,12 +159,14 @@ namespace Client
|
|||||||
{
|
{
|
||||||
Debug.WriteLine("[CLIENT] sending message " + Encoding.ASCII.GetString(message));
|
Debug.WriteLine("[CLIENT] sending message " + Encoding.ASCII.GetString(message));
|
||||||
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWriteComplete), null);
|
stream.BeginWrite(message, 0, message.Length, new AsyncCallback(OnWriteComplete), null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnWriteComplete(IAsyncResult ar)
|
private void OnWriteComplete(IAsyncResult ar)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("[CLIENT] finished writing");
|
Debug.WriteLine("[CLIENT] finished writing");
|
||||||
stream.EndWrite(ar);
|
stream.EndWrite(ar);
|
||||||
|
stream.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using static SharedClientServer.JSONConvert;
|
|||||||
|
|
||||||
namespace Server.Models
|
namespace Server.Models
|
||||||
{
|
{
|
||||||
|
public delegate void Callback();
|
||||||
class ServerClient : ObservableObject
|
class ServerClient : ObservableObject
|
||||||
{
|
{
|
||||||
private TcpClient tcpClient;
|
private TcpClient tcpClient;
|
||||||
@@ -24,6 +25,7 @@ namespace Server.Models
|
|||||||
private int totalBufferReceived = 0;
|
private int totalBufferReceived = 0;
|
||||||
public User User { get; set; }
|
public User User { get; set; }
|
||||||
private ServerCommunication serverCom = ServerCommunication.INSTANCE;
|
private ServerCommunication serverCom = ServerCommunication.INSTANCE;
|
||||||
|
private Callback OnMessageReceivedOk;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -159,6 +161,10 @@ namespace Server.Models
|
|||||||
case JSONConvert.RANDOMWORD:
|
case JSONConvert.RANDOMWORD:
|
||||||
//Flag byte for receiving the random word.
|
//Flag byte for receiving the random word.
|
||||||
break;
|
break;
|
||||||
|
case JSONConvert.MESSAGE_RECEIVED:
|
||||||
|
// we now can send a new message
|
||||||
|
OnMessageReceivedOk?.Invoke();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Debug.WriteLine("[SERVER] Received weird identifier: " + id);
|
Debug.WriteLine("[SERVER] Received weird identifier: " + id);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace SharedClientServer
|
|||||||
public const byte LOBBY = 0x03;
|
public const byte LOBBY = 0x03;
|
||||||
public const byte CANVAS = 0x04;
|
public const byte CANVAS = 0x04;
|
||||||
public const byte RANDOMWORD = 0x05;
|
public const byte RANDOMWORD = 0x05;
|
||||||
|
public const byte MESSAGE_RECEIVED = 0x06;
|
||||||
|
|
||||||
public enum LobbyIdentifier
|
public enum LobbyIdentifier
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user