public bool Open(object arg) { try { _headerLogRecord = Ashley.CreateHeader(AshleyVersion.V1_1, NetDebugLogTransmissionManager.ID_N1, (ulong)BiuNetDebugAction.LogRecord, AshleyFlag.Security); _headerLogRecord.Security.Alg = AshleySecurityAlg.P4S; _server.CC = new ConnectionCreation() { Trait = SocketTrait.Normal, Type = SocketType.IPv4TCP, Protocol = _ashley, Handler = BiuIoManager.Instance.Handlers[NetDebugLogTransmissionManager.Handler_DebugN1].Handler, EndPoint = this.DebugN1EndPoint, SecurityProvider = _securityProvider }; TransmissionRouter.Instance.AddHop(this); return(_server.Create(true)); } catch { throw; } }
public bool Initialize() { try { TransmissionManager.StartUpWSA(); _securityProvider = new SecurityProvider(); _securityProvider.NewItem(); _ashley = Ashley.CreateEntityProtocol(); _server = new AppServer(); BiuIoManager.Instance.NewHandler(NetDebugLogTransmissionManager.Handler_DebugN1, NetDebugLogTransmissionManager.ID_N1, 0, 0); //BiuIoManager.Instance.NewHandler(NetDebugLogTransmissionManager.Handler_DebugN1_Data, NetDebugLogTransmissionManager.ID_N1, 0, 0); _actionTable.Add(NetDebugLogTransmissionManager.Handler_DebugN1) .AddRow((ulong)BiuAction.Accept, IOOperation.Read) .AddRow((ulong)BiuAction.PublicKey, DebugN1_PublicKey); return(true); } catch { throw; } }
public IOOperation DispatchIo(string name, ulong action, Peer peer, ref bool handled) { IOOperation operation = IOOperation.Read; Ashley ashley = peer.Protocol; try { bool bHandled = false; if (null != this.MainHop) { operation = this.MainHop.HopIo(name, action, peer, ref handled); if (handled) { bHandled = true; } } foreach (var item in _dictHop.Values) { ITransmissionHop hop; if (!item.TryGetTarget(out hop)) { continue; } operation = hop.HopIo(name, action, peer, ref handled); if (handled) { bHandled = true; } } handled = bHandled; return(operation); } catch { throw; } finally { ashley.KillObject(); } }
public void Uninitialize() { try { BiuIoManager.Instance.RemoveHandler(NetDebugLogTransmissionManager.Handler_DebugN1); _server = null; _ashley.Dispose(); _ashley = null; _securityProvider.Dispose(); _securityProvider = null; TransmissionManager.CleanUpWSA(); } catch { throw; } }
private IOOperation DebugN1_PublicKey(BiuIoHopArgs arg) { var peer = arg.Peer; try { RawData raw = new RawData(); if (!peer.Protocol.GetObjKept <RawData>(ref raw)) { return(IOOperation.None); } AshleyHeader header = Ashley.CreateHeader(AshleyVersion.V1_1, NetDebugLogTransmissionManager.ID_N1, (ulong)BiuAction.Ack, AshleyFlag.None); Ack ack = new Ack() { AckAction = (ulong)BiuAction.PublicKey, AckResult = (uint)BiuAckResult.OK }; if (null == peer.SecurityContext) { ack.AckResult = (uint)BiuAckResult.Unsupported; } else if (!peer.SecurityContext.ChangeRemoateKey(raw.Raw.ToArray())) { ack.AckResult = (uint)BiuAckResult.Failed; } peer.Return(ack, header); return(IOOperation.Continue); } catch { throw; } }
void DebugN1_Accepted(Peer peer, BoolArg arg) { arg.RetuenValue = true; if (null != peer.SecurityContext) { RawData raw = new RawData() { Raw = peer.SecurityContext.ExportKey().ToList() }; AshleyHeader header = Ashley.CreateHeader(AshleyVersion.V1_1, NetDebugLogTransmissionManager.ID_N1, (ulong)BiuAction.PublicKey, AshleyFlag.None); peer.Send(raw, header); } try { UserLogin(peer); } catch { } }