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>
|
||||
public bool LineExists(string lineId)
|
||||
{
|
||||
if(currentLines[lineId] != null)
|
||||
if(currentLines.ContainsKey(lineId))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -162,16 +162,25 @@ namespace Nibriboard.Client
|
|||
if(eventName != "CursorPosition")
|
||||
Log.WriteLine("[NibriClient#{0}] Recieved message with event {1}.", Id, eventName);
|
||||
|
||||
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 });
|
||||
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 });
|
||||
|
||||
string handlerMethodName = "handle" + decodedMessage.GetType().Name;
|
||||
Type clientType = this.GetType();
|
||||
MethodInfo handlerInfo = clientType.GetMethod(handlerMethodName, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
await (Task)handlerInfo.Invoke(this, new object[] { decodedMessage });
|
||||
string handlerMethodName = "handle" + decodedMessage.GetType().Name;
|
||||
Type clientType = this.GetType();
|
||||
MethodInfo handlerInfo = clientType.GetMethod(handlerMethodName, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
await (Task)handlerInfo.Invoke(this, new object[] { decodedMessage });
|
||||
}
|
||||
catch(Exception error)
|
||||
{
|
||||
Log.WriteLine("[NibriClient#{0}] Error decoding and / or handling message.", Id);
|
||||
Log.WriteLine("[NibriClient#{0}] Raw frame content: {1}", Id, frame);
|
||||
Log.WriteLine("[NibriClient#{0}] Exception details: {1}", Id, error);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue