public Proto(string rout, ProtoType p_t, string c2s, string s2c) { this.route = rout; this.ptype = p_t; this.c2sdt = c2s; this.s2cdt = s2c; }
public INetSession CreateLSSession( ProtoType type, X509Certificate2 certificate ) { LoginSession session = NetSessionPool.instance.Pop<LoginSession>( type, certificate ); session.owner = this; session.type = SessionType.ServerLS; return session; }
// private byte[] GetKcpLuaProtocolBytes(Proto.ReqKcpLuaMessage protocol) // { // try // { // var bytes = new List<byte>(); // var props = propsJsonDict[protocol.ID]; // var data = JObject.Parse(protocol.Data); // for (int i = 1; i < props.Table.Length; i++) // { // bytes.AddRange(SerializeJsonTools.GetObjectBytes(data, props.Table[i])); // } // return bytes.ToArray(); // } // catch(Exception e) // { // Debug.Log("GetKcpLuaProtocolBytes e:" + e.ToString()); // return null; // } // } public byte[] GetBytes(IProtocol protocol) { var bID = BitConverter.GetBytes(protocol.ID); byte[] bytes; ProtoType type = CheckIsLuaProto(protocol.ID); switch (type) { case ProtoType.TcpLuaProto: bytes = GetLuaProtocolBytes((ReqLuaMessage)protocol); break; case ProtoType.KcpLuaProto: bytes = GetLuaProtocolBytes((ReqLuaMessage)protocol); break; case ProtoType.TcpCsProto: bytes = GetProtocolBytes(protocol); break; default: bytes = GetLuaProtocolBytes((ReqLuaMessage)protocol); break; } var bLen = BitConverter.GetBytes((int)(bytes.Length + 2)); var ret = new byte[bytes.Length + 6]; Buffer.BlockCopy(bLen, 0, ret, 0, 4); Buffer.BlockCopy(bID, 0, ret, 4, 2); Buffer.BlockCopy(bytes, 0, ret, 6, bytes.Length); return(ret); }
public virtual void Deal(LuaFunction dealFunc) { try { if (dealFunc != null) { GameMainLoopManager.Instance.AddActionDoInMainThread(() => { var luaState = LuaFileManager.Instance.luaState; if (luaState != null) { ProtoType type = ProtocolFactory.CheckIsLuaProto(ID); if (type == ProtoType.TcpLuaProto) { dealFunc.Call <int, string>(ID, Data.ToString()); } else { dealFunc.Call <int, string>(ID, JsonConvert.SerializeObject(this)); } } }); } } catch (System.Exception e) { Debug.LogWarning(e.Message); } }
public static ExtractMessagesResult ExtractMessages(ProtoType type, byte[] buffer) { ExtractMessagesResult result = new ExtractMessagesResult(); switch (type) { case ProtoType.Handshake: CreateHandshakeMessages(buffer, result); break; case ProtoType.ChangeCipherSpec: CCSProtocolMessage cMsg = CreateCCSMessage(buffer); result.protocolMessages.Add(cMsg); break; case ProtoType.Alert: AlertProtocolMessage aMsg = CreateAlertMessage(buffer); result.protocolMessages.Add(aMsg); break; case ProtoType.ApplicationData: ApplicationProtocolMessage apm = CreateAPMessage(buffer); result.protocolMessages.Add(apm); break; } return(result); }
protected BattleSession(uint id, ProtoType type, X509Certificate2 certificate) : base(id, type, certificate) { this.RegMsgHandler(Protos.MsgID.EGAskPing, CS.instance.bizProcessor.OnBSAskPing); this.RegMsgHandler(Protos.MsgID.EBs2CsReportState, CS.instance.bizProcessor.OnBs2CsReportState); this.RegMsgHandler(Protos.MsgID.EBs2CsBattleEnd, CS.instance.bizProcessor.OnBs2CsBattleEnd); this.RegMsgHandler(Protos.MsgID.EBs2CsKickUser, CS.instance.bizProcessor.OnBs2CsKickUser); }
public T Pop <T>(ProtoType protoType, X509Certificate2 certificate) where T : INetSession { lock (this._typeToObjects) { Type type = typeof(T); if (!this._typeToObjects.TryGetValue(type, out Queue <INetSession> objs)) { objs = new Queue <INetSession>(); this._typeToObjects[type] = objs; } if (objs.Count == 0) { if (_gid == uint.MaxValue) { Logger.Warn("id reach the limit!!"); _gid = 0; } uint id = ++_gid; return(( T )Activator.CreateInstance(typeof(T), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { id, protoType, certificate }, null)); } objs.TryDequeue(out INetSession session); return(( T )session); } }
private static ProtoType ToProto(FuncInfo fi) { var proto = new ProtoType { NumParams = (byte)fi.NumParams, MaxStackSize = (byte)fi.MaxRegs, Code = fi.Insts.ToArray(), Constatns = GetConstants(fi), Upvalues = GetUpvalues(fi), Protos = ToProtos(fi.SubFuncs), LineInfo = new uint[0], LocVars = new LocVar[0], UpvalueNames = new string[0] }; if (proto.MaxStackSize < 2) { proto.MaxStackSize = 2; } if (fi.IsVararg) { proto.IsVararg = 1; } return(proto); }
public RecordLayer.Record FromByteQueue(ByteQueue queue) { if (queue.Length == 0) { return(null); } else { if (queue.Length >= 5) { byte[] recordHeader = queue.Peek(5); ProtoType recordType = (ProtoType)recordHeader[0]; ProtocolVersion version = new ProtocolVersion(recordHeader[1], recordHeader[2]); /* TODO: Check for the right version */ if (BitConverter.IsLittleEndian) { Array.Reverse(recordHeader, 3, 2); } int payloadLength = BitConverter.ToUInt16(recordHeader, 3); if (queue.Length < payloadLength) { throw new SslInsufficientReceiveException(); } queue.Dequeue(5); // discard header return(new RecordLayer.Record(queue.Dequeue(payloadLength), recordType, version)); } else { throw new SslInsufficientReceiveException(); } } }
protected ClientSession(uint id, ProtoType type, X509Certificate2 certificate) : base(id, type, certificate) { this._accreditedMsgID = Protos.MsgID.EGc2GsAskLogin; this.RegMsgHandler(Protos.MsgID.EGc2GsAskLogin, GS.instance.bizProcessor.OnGC2GSAskLogin); this.RegMsgHandler(Protos.MsgID.EGc2GsKeepAlive, GS.instance.bizProcessor.OnGc2GsKeepAlive); }
void Send(byte[] data, ProtoType msgType) { if (data == null) { Debug.LogError("发送数据错误"); return; } switch (msgType) { case ProtoType.Importance: client.SendMsg(data); break; case ProtoType.Unimportance: if (differentUdpPort) { foreach (var ip in broadCastList) { multidataConnection.SendTo(data, ip.Value); } } else { multidataConnection.BroadCast(data); } break; } }
public int Load(byte[] chunk, string chunkName, string mode) { ProtoType proto = null; if (ProtoType.IsBinaryChunk(chunk)) { proto = ProtoType.Undump(chunk); } else { var chars = new char[chunk.Length]; Array.Copy(chunk, chars, chars.Length); proto = Compiler.Compile(new string(chars), chunkName); } var c = new Closure(proto); _stack.Push(c); if (proto.Upvalues.Length > 0) { var env = _registry.Get(Consts.LUA_RIDX_GLOBALS); c.Upvals[0] = new Upvalue { Val = env }; } return((int)EErrorCode.Ok); }
/// <summary> /// 通过配置文件绑定GridIndex,允许玩家在冲突时自定义GridIndex /// 在自定义ID之后执行 /// </summary> private static void GridIndexBind(ProtoType protoType, Proto proto) { if (proto is ItemProto || proto is RecipeProto) // 只有物品和配方有GridIndex { ConfigEntry <int> entry = null; if (proto is ItemProto) { var item = proto as ItemProto; entry = CustomGridIndex.Bind <int>(protoType.ToString(), item.ID.ToString(), item.GridIndex, $"Item Name = {item.Name}"); item.GridIndex = entry.Value; } else if (proto is RecipeProto) { var recipe = proto as RecipeProto; entry = CustomGridIndex.Bind <int>(protoType.ToString(), recipe.ID.ToString(), recipe.GridIndex, $"Recipe Name = {recipe.Name}"); recipe.GridIndex = entry.Value; } if (entry != null) { if (!GridIndexDict.ContainsKey(protoType)) { GridIndexDict.Add(protoType, new Dictionary <string, ConfigEntry <int> >()); } if (GridIndexDict[protoType].ContainsKey(proto.Name)) { Debug.LogError($"[LDBTool.CustomGridIndex]ID:{proto.ID} Name:{proto.Name} There is a conflict, please check."); Debug.LogError($"[LDBTool.CustomGridIndex]ID:{proto.ID} 姓名:{proto.Name} 存在冲突,请检查。"); } else { GridIndexDict[protoType].Add(proto.Name, entry); } } } }
/// <summary> /// Funzione per la restituzione dell'oggetto preposto all'importazione dei /// documenti di una determinata tipologia /// </summary> /// <param name="protoType">Il tipo di protocollo da importare</param> /// <returns>L'oggetto adatto ad effettuare l'importazione dei documenti della tipologia specificata</returns> private static Document GetDocumentManager(ProtoType protoType) { // L'oggetto da restituire Document toReturn = null; switch (protoType) { case ProtoType.A: // Arrivo toReturn = new InDocument(); break; case ProtoType.P: // Partenza toReturn = new OutDocument(); break; case ProtoType.G: // Grigio toReturn = new GrayDocument(); break; case ProtoType.I: // Interno toReturn = new OwnDocument(); break; } // Restituzione del risultato return(toReturn); }
public INetSession CreateShellSession(ProtoType type, X509Certificate2 certificate) { ShellSession session = NetSessionPool.instance.Pop <ShellSession>(type, certificate); session.owner = this; session.type = SessionType.Shell; return(session); }
public INetSession CreateClientSession(ProtoType type, X509Certificate2 certificate) { ClientSession session = NetSessionPool.instance.Pop <ClientSession>(type, certificate); session.owner = this; session.type = SessionType.ServerGC; return(session); }
public INetSession CreateBSSession(ProtoType type, X509Certificate2 certificate) { BattleSession session = NetSessionPool.instance.Pop <BattleSession>(type, certificate); session.owner = this; session.type = SessionType.ServerBS; return(session); }
public Closure(ProtoType proto) { Proto = proto; if (proto.Upvalues.Length > 0) { Upvals = new Upvalue[proto.Upvalues.Length]; } }
/// <summary> /// 在游戏数据加载之后添加数据 /// </summary> /// <param name="protoType">要添加的Proto的类型</param> /// <param name="proto">要添加的Proto</param> public static void PostAddProto(ProtoType protoType, Proto proto) { if (!PostToAdd[protoType].Contains(proto)) { Bind(protoType, proto); PostToAdd[protoType].Add(proto); TotalDict[protoType].Add(proto); } }
/// <summary> /// Constructs an event arguments /// </summary> /// <param name="host">Hostname or IP address</param> /// <param name="port">IP Port</param> /// <param name="protocol">Protocol</param> public RemoteReportedEventArgs(string host, int port, ProtoType protocol) { Host = host; Port = port; Protocol = protocol; // Default action is accept. Action = new RemoteAcceptAction(); }
public MessageConfigAttribute(ProtoType protoType, string route, Type inType, Type outType, int overridePriority = 1, bool bGenProto = true) { this.protoType = protoType; this.route = route; this.inType = inType; this.outType = outType; this.overridePriority = overridePriority; this.genProto = bGenProto; }
public void SendData <T>(NetPeer peer, ProtoType protoType, string protoName, T t) { var bytes = Serialize <T>(t); if (bytes != null) { SendDataInternal(peer, protoType, protoName, bytes); } }
/// <summary> /// 在游戏数据加载之前添加数据 /// </summary> /// <param name="protoType">要添加的Proto的类型</param> /// <param name="proto">要添加的Proto</param> public static void PreAddProto(ProtoType protoType, Proto proto) { if (!PreToAdd[protoType].Contains(proto)) { IdBind(protoType, proto); PreToAdd[protoType].Add(proto); TotalDict[protoType].Add(proto); } }
public void ReadUnknow(ProtoType type) { switch (type) { case ProtoType.VarInt: { ReadInt(); break; } case ProtoType.VarLong: { ReadLong(); break; } case ProtoType.String: { ReadString(); break; } case ProtoType.VarIntList: { ReadIntList(); break; } case ProtoType.VarLongList: { ReadLongList(); break; } case ProtoType.StringList: { ReadStringList(); break; } case ProtoType.Object: { ReadUnknowObject(); break; } case ProtoType.ObjectList: { ReadUnknowObjectList(); break; } default: break; } }
private void SendDataInternal(NetPeer peer, ProtoType protoType, string protoName, byte[] buffer) { var writer = new NetDataWriter(); writer.Put((byte)protoType); writer.Put(protoName); writer.Put(buffer.Length); writer.Put(buffer); peer.Send(writer, DeliveryMethod.ReliableOrdered); }
public static ImportResult ImportAndAcquireDocument( DocumentRowData documentToImport, ProtoType protoType, string serverPath, InfoUtente userInfo, Ruolo role, ref ResultsContainer resultsContainer) { // Impostazione del timeout ad infinito ws.Timeout = System.Threading.Timeout.Infinite; // Lettura del valore di configurazione utilizzato per indicare // se è obbligatoria la profilazione del documento bool isProfilationRequired = false; //Boolean.TryParse( // ConfigurationManager.AppSettings["TIPO_ATTO_REQUIRED"], // out isProfilationRequired); string idAmm = userInfo.idAmministrazione; if (DocumentManager.GetTipoDocObbl(idAmm).Equals("1")) { isProfilationRequired = true; } // Lettura del valore di configurazione utilizzato per indicare // se è obbligatoria la classificazione del documento bool isClassificationRequired = false; if (!string.IsNullOrEmpty(Utils.InitConfigurationKeys.GetValue(UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_FASC_RAPIDA_REQUIRED.ToString()))) { isClassificationRequired = bool.Parse(Utils.InitConfigurationKeys.GetValue(UserManager.GetInfoUser().idAmministrazione, DBKeys.FE_FASC_RAPIDA_REQUIRED.ToString())); } try { // Chiamata del webservice per l'importazione dei documenti da // foglio Excel e restituzione della lista dei risultati return(ws.ImportAndAcquireDocument( documentToImport, protoType, serverPath, userInfo, role, isProfilationRequired, isClassificationRequired, false, ref resultsContainer, importazionePregressiAbilitata())); } catch (Exception e) { throw new Exception("Ricevuto errore dal servizio."); } }
public override int GetHashCode() { unchecked { int hashCode = ProtoType.GetHashCode(); hashCode = (hashCode * 397) ^ (ServerAddress != null ? ServerAddress.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProviderName != null ? ProviderName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DoHPath != null ? DoHPath.GetHashCode() : 0); return(hashCode); } }
private static ProtoType[] ToProtos(List <FuncInfo> fis) { var protos = new ProtoType[fis.Count]; for (var i = 0; i < fis.Count; i++) { protos[i] = ToProto(fis[i]); } return(protos); }
/// <summary> /// 发送数据 /// </summary> public void SendBytes(byte protoID, byte[] obj, ProtoType msgType) { #if UNITY_EDITOR sendSampler.Begin(); #endif byte[] data = Util.SerializeProtoData(protoID, obj); Send(data, msgType); #if UNITY_EDITOR sendSampler.End(); #endif }
public void SendData(ClientPeer clientPeer, ProtoType protoType, string protoName, IMessage msg) { var buffer = msg.Serialize(); var writer = new NetDataWriter(); writer.Put((byte)protoType); writer.Put(protoName); writer.Put(buffer.Length); writer.Put(buffer); clientPeer.peer.Send(writer, DeliveryMethod.ReliableOrdered); }