mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[server] Fix LineIncubator->LineExists()
This commit is contained in:
parent
9cd578512b
commit
96485f3f0e
2 changed files with 20 additions and 11 deletions
|
@ -39,7 +39,7 @@ namespace Nibriboard.Client
|
||||||
/// <param name="lineId">The line id to check for.</param>
|
/// <param name="lineId">The line id to check for.</param>
|
||||||
public bool LineExists(string lineId)
|
public bool LineExists(string lineId)
|
||||||
{
|
{
|
||||||
if(currentLines[lineId] != null)
|
if(currentLines.ContainsKey(lineId))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,17 +161,26 @@ namespace Nibriboard.Client
|
||||||
}
|
}
|
||||||
if(eventName != "CursorPosition")
|
if(eventName != "CursorPosition")
|
||||||
Log.WriteLine("[NibriClient#{0}] Recieved message with event {1}.", Id, eventName);
|
Log.WriteLine("[NibriClient#{0}] Recieved message with event {1}.", Id, eventName);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Type messageType = messageEventTypes[eventName];
|
||||||
|
Type jsonNet = typeof(JsonConvert);
|
||||||
|
MethodInfo deserialiserInfo = jsonNet.GetMethods().First(method => method.Name == "DeserializeObject" && method.IsGenericMethod);
|
||||||
|
MethodInfo genericInfo = deserialiserInfo.MakeGenericMethod(messageType);
|
||||||
|
var decodedMessage = genericInfo.Invoke(null, new object[] { frame });
|
||||||
|
|
||||||
Type messageType = messageEventTypes[eventName];
|
string handlerMethodName = "handle" + decodedMessage.GetType().Name;
|
||||||
Type jsonNet = typeof(JsonConvert);
|
Type clientType = this.GetType();
|
||||||
MethodInfo deserialiserInfo = jsonNet.GetMethods().First(method => method.Name == "DeserializeObject" && method.IsGenericMethod);
|
MethodInfo handlerInfo = clientType.GetMethod(handlerMethodName, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
MethodInfo genericInfo = deserialiserInfo.MakeGenericMethod(messageType);
|
await (Task)handlerInfo.Invoke(this, new object[] { decodedMessage });
|
||||||
var decodedMessage = genericInfo.Invoke(null, new object[] { frame });
|
}
|
||||||
|
catch(Exception error)
|
||||||
string handlerMethodName = "handle" + decodedMessage.GetType().Name;
|
{
|
||||||
Type clientType = this.GetType();
|
Log.WriteLine("[NibriClient#{0}] Error decoding and / or handling message.", Id);
|
||||||
MethodInfo handlerInfo = clientType.GetMethod(handlerMethodName, BindingFlags.Instance | BindingFlags.NonPublic);
|
Log.WriteLine("[NibriClient#{0}] Raw frame content: {1}", Id, frame);
|
||||||
await (Task)handlerInfo.Invoke(this, new object[] { decodedMessage });
|
Log.WriteLine("[NibriClient#{0}] Exception details: {1}", Id, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue