internal bool InvokeChannelExist(string channelName) { var data = MessageFormatter.FromChannelExist(channelName); var head = new byte[17]; head[0] = 0; var id = Guid.NewGuid(); id.ToByteArray().CopyTo(head, 1); bool completed = false; while (!completed) { try { Client.Send(data, head); IOManager.BeginMessage(id); completed = true; } catch { } } return(IOManager.EndMessage(id)[0] == 1); }
internal object InvokeMethod(string channelName, string methodName, int methodIndex, object[] args, Type returnType) { var data = MessageFormatter.FromChannelMethodInvoke(channelName, methodIndex, args); var head = new byte[17]; head[0] = 3; var id = Guid.NewGuid(); id.ToByteArray().CopyTo(head, 1); ServiceContext.Current.User.Client.Send(data, head); IOManager.BeginMessage(id); object result; string errorMsg; MessageFormatter.ToChannelMethodResult(IOManager.EndMessage(id), returnType, out result, out errorMsg); if (errorMsg == null) { return(result); } switch (errorMsg) { case "ChannelNotExist": throw new ChannelNotExistException(channelName, ServiceContext.Current.User.Client.EndPoint); case "MethodNotExist": throw new MethodNotExistException(channelName, methodName, ServiceContext.Current.User.Client.EndPoint); case "MethodParametersError": throw new MethodParamaterException(channelName, methodName, ServiceContext.Current.User.Client.EndPoint, args); case "MethodRuntimeError": throw new MethodRuntimeException(channelName, methodName, ServiceContext.Current.User.Client.EndPoint); } return(null); }