static int SendExtensionRequest(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2) { MessageTransmitter obj = LuaScriptMgr.GetNetObject <MessageTransmitter>(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 2); obj.SendExtensionRequest(arg0); return(0); } else if (count == 3) { MessageTransmitter obj = LuaScriptMgr.GetNetObject <MessageTransmitter>(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 2); com.gt.entities.IMPObject arg1 = LuaScriptMgr.GetNetObject <com.gt.entities.IMPObject>(L, 3); obj.SendExtensionRequest(arg0, arg1); return(0); } else if (count == 4) { MessageTransmitter obj = LuaScriptMgr.GetNetObject <MessageTransmitter>(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 2); com.gt.entities.IMPObject arg1 = LuaScriptMgr.GetNetObject <com.gt.entities.IMPObject>(L, 3); bool arg2 = LuaScriptMgr.GetBoolean(L, 4); obj.SendExtensionRequest(arg0, arg1, arg2); return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: MessageTransmitter.SendExtensionRequest"); } return(0); }
public bool ReceivedMessage(Message msg, MessageTransmitter transmitter) { float distanceSqr = (transform.position - msg.creationPosition).sqrMagnitude; if (distanceSqr <= (msg.range * msg.range)) { float shipRotation = 0.0f; if (msg.commandType == Message.CommandType.Begin) { shipRotation = msg.left ? 1.0f : 0.0f; shipRotation += msg.right ? -1.0f : 0.0f; } else if (msg.commandType == Message.CommandType.End) { shipRotation = 0.0f; } ship.RotationRate = shipRotation; audioSource.pitch = Random.Range(.9f, 1.1f); audioSource.PlayOneShot(thrusterTurnSound); return(true); } return(false); }
public void TestSubscriptionOfSingleObserver() { using (IMessageTransmitter transmitter = new MessageTransmitter(new XmlMessageStreamReader(this.BaseStream), new XmlMessageStreamWriter(this.BaseStream), this.BaseStream)) { Mock <IObserver <IMessage> > observerMock = new Mock <IObserver <IMessage> >(); using (ManualResetEventSlim sync = new() ) { observerMock.Setup(x => x.OnCompleted()).Callback(() => { sync.Set(); }); IConnectableObservable <IMessage> observable = transmitter; using (IDisposable subscription = transmitter.Subscribe(observerMock.Object)) { observable.Connect(); sync.Wait(); observerMock.Verify(x => x.OnNext(It.IsAny <IMessage>()), Times.Exactly(this.Messages.Count)); Assert.IsNotNull(subscription); } } } }
public LogEventMsgSet(AsyncLogEventInfo asyncLogEvent, ByteArray buffer, MessageBuilder messageBuilder, MessageTransmitter messageTransmitter) { this.asyncLogEvent = asyncLogEvent; this.buffer = buffer; this.messageBuilder = messageBuilder; this.messageTransmitter = messageTransmitter; currentMessage = 0; }
public AsyncLogger(Layout loggingLayout, EnforcementConfig enforcementConfig, MessageBuilder messageBuilder, MessageTransmitterConfig messageTransmitterConfig) { layout = loggingLayout; cts = new CancellationTokenSource(); token = cts.Token; throttling = Throttling.FromConfig(enforcementConfig.Throttling); queue = NewBlockingCollection(); buffer = new ByteArray(enforcementConfig.TruncateMessageTo); messageTransmitter = MessageTransmitter.FromConfig(messageTransmitterConfig); Task.Run(() => ProcessQueueAsync(messageBuilder)); }
public AsyncLogger(Layout loggingLayout, EnforcementConfig enforcementConfig, MessageBuilder messageBuilder, MessageTransmitterConfig messageTransmitterConfig) { layout = loggingLayout; cts = new CancellationTokenSource(); token = cts.Token; throttling = Throttling.FromConfig(enforcementConfig.Throttling); queue = NewBlockingCollection(); buffer = new ByteArray(enforcementConfig.TruncateMessageTo); messageTransmitter = MessageTransmitter.FromConfig(messageTransmitterConfig); flushCompletionMarker = new LogEventInfo(LogLevel.Off, string.Empty, nameof(flushCompletionMarker)); Task.Run(() => ProcessQueueAsync(messageBuilder)); processWithTimeoutAction = (asyncLogEventInfo, timeout) => Enqueue(asyncLogEventInfo, timeout); discardAction = asyncLogEventInfo => asyncLogEventInfo.Continuation(new InvalidOperationException($"Enqueue skipped")); }
static int _CreateMessageTransmitter(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 1) { int arg0 = (int)LuaScriptMgr.GetNumber(L, 1); MessageTransmitter obj = new MessageTransmitter(arg0); LuaScriptMgr.PushObject(L, obj); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: MessageTransmitter.New"); } return(0); }
static int get_PrefabConnecterId(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); MessageTransmitter obj = (MessageTransmitter)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name PrefabConnecterId"); } else { LuaDLL.luaL_error(L, "attempt to index PrefabConnecterId on a nil value"); } } LuaScriptMgr.Push(L, obj.PrefabConnecterId); return(1); }
public void TestSubscriptionOfMultipleObservers() { using (IMessageTransmitter transmitter = new MessageTransmitter(new XmlMessageStreamReader(this.BaseStream), new XmlMessageStreamWriter(this.BaseStream), this.BaseStream)) { Mock <IObserver <IMessage> > observerMock1 = new Mock <IObserver <IMessage> >(); Mock <IObserver <IMessage> > observerMock2 = new Mock <IObserver <IMessage> >(); using (ManualResetEventSlim observerMock1Sync = new ManualResetEventSlim()) { using (ManualResetEventSlim observerMock2Sync = new ManualResetEventSlim()) { observerMock1.Setup(x => x.OnCompleted()).Callback(() => { observerMock1Sync.Set(); }); observerMock2.Setup(x => x.OnCompleted()).Callback(() => { observerMock2Sync.Set(); }); IConnectableObservable <IMessage> observable = transmitter; observable.Subscribe(observerMock1.Object); observable.Subscribe(observerMock2.Object); observable.Connect(); observerMock1Sync.Wait(); observerMock2Sync.Wait(); observerMock1.Verify(x => x.OnNext(It.IsAny <IMessage>()), Times.Exactly(this.Messages.Count)); observerMock2.Verify(x => x.OnNext(It.IsAny <IMessage>()), Times.Exactly(this.Messages.Count)); } } } }
public virtual void Transmit <T>(T item) { MessageTransmitter.Transmit(item); }
public MessageSenderImpl(GuidProxy guidProxy, UnacknowledgedReliableMessageContainer unacknowledgedReliableMessageContainer, MessageTransmitter messageTransmitter) { this.guidProxy = guidProxy; this.unacknowledgedReliableMessageContainer = unacknowledgedReliableMessageContainer; this.messageTransmitter = messageTransmitter; }