protected void DispatchPacket(List <MessageElement> me, WireConnection e) { TimeSpec timespec; var data = UnpackPacket(me, out timespec); e.WirePacketReceived(timespec, (T)data); }
public void OnWireAdded(WireConnection con) { ISignalNodeProvider dev1 = GetDeviceAt(con.pos1.blockPos); ISignalNodeProvider dev2 = GetDeviceAt(con.pos2.blockPos); if (dev1 == null || dev2 == null) { return; } //wireConnections.Add(con); GetDeviceAt(con.pos1.blockPos)?.GetNodeAt(con.pos1)?.Connections.Add(con); GetDeviceAt(con.pos2.blockPos)?.GetNodeAt(con.pos2)?.Connections.Add(con.GetReversed()); TryToAddConnection(con); TryToAddConnection(con.GetReversed()); }
protected override async Task Close(WireConnection c, Endpoint e = null, CancellationToken cancel = default(CancellationToken)) { Task mutex = Close_mutex.Enter(); try { await mutex; MessageEntry m = new MessageEntry(MessageEntryType.WireDisconnectReq, MemberName); MessageEntry ret = await stub.ProcessRequest(m, cancel); connection = null; } finally { Close_mutex.Exit(mutex); } }
public async override Task <WireConnection> Connect(CancellationToken cancel = default(CancellationToken)) { try { lock (connect_lock) { if (connection != null) { throw new InvalidOperationException("Already connected"); } connection = new WireConnection(this); } MessageEntry m = new MessageEntry(MessageEntryType.WireConnectReq, MemberName); MessageEntry ret = await stub.ProcessRequest(m, cancel); return(connection); } catch (Exception e) { connection = null; throw e; } }
protected abstract Task Close(WireConnection c, Endpoint e = null, CancellationToken cancel = default(CancellationToken));