- Added ReadInput() Method, returns string of what is sent to server.
- Send method receives a string and sends the data - Receive method receives a string instead of bytes now. - Server simply uses ReadInput method.
This commit is contained in:
parent
607bd673a5
commit
942b038b1b
2 changed files with 39 additions and 29 deletions
|
@ -99,21 +99,7 @@ namespace MudEngine.Networking
|
|||
{
|
||||
try
|
||||
{
|
||||
byte[] buf = new byte[1];
|
||||
int recved = players[sub].client.Receive(buf);
|
||||
|
||||
if (recved > 0)
|
||||
{
|
||||
if (buf[0] == '\n' && buffer.Count > 0)
|
||||
{
|
||||
if (buffer[buffer.Count-1] == '\r')
|
||||
buffer.RemoveAt(buffer.Count-1);
|
||||
players[sub].Receive(buffer.ToArray());
|
||||
buffer.Clear();
|
||||
}
|
||||
else
|
||||
buffer.Add(buf[0]);
|
||||
}
|
||||
players[sub].Receive(players[sub].ReadInput());
|
||||
}
|
||||
catch (Exception) // error receiving, close player
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue