TelepathyTransport - switches (#221)

This commit is contained in:
MichalPetryka 2019-01-02 14:07:00 +01:00 committed by Paul Pacheco
parent 52d6792f73
commit b96c92c0de

View File

@ -30,16 +30,23 @@ public virtual bool ClientGetNextMessage(out TransportEvent transportEvent, out
{
Telepathy.Message message;
if (client.GetNextMessage(out message))
{
switch (message.eventType)
{
// convert Telepathy EventType to TransportEvent
if (message.eventType == Telepathy.EventType.Connected)
case Telepathy.EventType.Connected:
transportEvent = TransportEvent.Connected;
else if (message.eventType == Telepathy.EventType.Data)
break;
case Telepathy.EventType.Data:
transportEvent = TransportEvent.Data;
else if (message.eventType == Telepathy.EventType.Disconnected)
break;
case Telepathy.EventType.Disconnected:
transportEvent = TransportEvent.Disconnected;
else
break;
default:
transportEvent = TransportEvent.Disconnected;
break;
}
// assign rest of the values and return true
data = message.data;
@ -64,16 +71,23 @@ public virtual bool ServerGetNextMessage(out int connectionId, out TransportEven
{
Telepathy.Message message;
if (server.GetNextMessage(out message))
{
switch (message.eventType)
{
// convert Telepathy EventType to TransportEvent
if (message.eventType == Telepathy.EventType.Connected)
case Telepathy.EventType.Connected:
transportEvent = TransportEvent.Connected;
else if (message.eventType == Telepathy.EventType.Data)
break;
case Telepathy.EventType.Data:
transportEvent = TransportEvent.Data;
else if (message.eventType == Telepathy.EventType.Disconnected)
break;
case Telepathy.EventType.Disconnected:
transportEvent = TransportEvent.Disconnected;
else
break;
default:
transportEvent = TransportEvent.Disconnected;
break;
}
// assign rest of the values and return true
connectionId = message.connectionId;