public void Open() { NetConfig config = new NetConfig(); config.Host = ServerConfig.Host; config.Port = ServerConfig.Port; config.CertificateFile = ServerConfig.CertificateFile; config.CertificatePassword = ServerConfig.CertificatePassword; if (!string.IsNullOrEmpty(config.CertificateFile)) { config.SSL = true; } HttpPacket hp = new HttpPacket(this.ServerConfig.BodySerializer, this.ServerConfig); mServer = SocketFactory.CreateTcpServer(config, this, hp); mServer.Open(); if (mAssemblies != null) { foreach (System.Reflection.Assembly assembly in mAssemblies) { mResourceCenter.LoadManifestResource(assembly); } } mResourceCenter.Path = ServerConfig.StaticResourcePath; mResourceCenter.Debug = ServerConfig.Debug; mResourceCenter.Load(); }
private static void Initialize() { ParentServerConfig = new ParentConfig(2); ServerConfig = new NetConfig(); ServerConfig.SetMaxBackLogConnections(MAXIMUM_BACKLOG); ServerConfig.SetMaxConnections(MAXIMUM_CONNECTIONS); ServerConfig.SetMaxMessageSize(MESSAGE_SIZE); ServerConfig.SetBufferSize(BUFFER_SIZE); ServerConfig.SetHeaderSize(HEADER_SIZE); ServerConfig.SetEnableKeepAlive(false); ServerConfig.SetPort(1660); ParentServer = new Parent(ParentServerConfig, ServerConfig); ParentServer.OnParentCreatedEvent += ParentServer_OnParentCreatedEvent; ParentServer.OnParentClosedEvent += ParentServer_OnParentClosedEvent; ParentServer.OnExceptionEvent += ParentServer_OnExceptionEvent; ParentServer.OnChildCreateEvent += ParentServer_OnChildCreateEvent; ParentServer.OnChildConnectEvent += ParentServer_OnChildConnectEvent; ParentServer.OnChildAuthenticateEvent += ParentServer_OnChildAuthenticateEvent; ParentServer.OnChildSendEvent += ParentServer_OnChildSendEvent; ParentServer.OnChildReceiveEvent += ParentServer_OnChildReceiveEvent; ParentServer.OnChildDisconnectEvent += ParentServer_OnChildDisconnectEvent; ParentServer.OnChildDestroyEvent += ParentServer_OnChildDestroyEvent; Input = new InputQueue(ParentServer); Output = new OutputQueue(); Output.OnFrameEvent += Output_OnFrameEvent; ParentServer.StartParent(); PacketHandler = new PacketHandler(Input, Output, MainLogger); ConnectPipeline(); Pipeline.SendMessage(new IViewNet.Common.Models.Packet(1111, "SetDetectionType", new byte[1024 * 19])); Console.ReadKey(); }
protected override void OnStart(string[] args) { if (!OtherConfig.init()) { return; } LogUtil.getInstance().start(OtherConfig.s_logPath + "TLJ_LoginServiceLog"); if (!NetConfig.init()) { return; } m_serverUtil = new HPServerUtil(); m_mySqlServerUtil = new MySqlServerUtil(); m_logicServerUtil = new LogicServerUtil(); //m_playServerUtil = new PlayServerUtil(); LogUtil.getInstance().addDebugLog("服务开启"); // 开启TCP服务组件与客户端通信 m_serverUtil.startTCPService(); // 开启TCP客户端组件与数据库服务器通信 m_mySqlServerUtil.start(); // 开启TCP客户端组件与逻辑服务器通信 m_logicServerUtil.start(); //// 开启TCP客户端组件与游戏服务器通信 //m_playServerUtil.start(); }
public async Task getAllData() { UINetLoadingComponent.showNetLoading(); try { await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/tips.json", TipsConfig.getInstance().init); await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/prop.json", PropConfig.getInstance().init); await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/zhuanpan.json", ZhuanPanConfig.getInstance().init); await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/notice.json", NoticeConfig.getInstance().init); await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/friendRoomConfig.json", FriendRoomConfig.getInstance().init); //await SensitiveWordUtil.Req("http://fwdown.hy51v.com/online/file/stopwords.txt"); string data = CommonUtil.getTextFileByBundle("config", "stopwords"); SensitiveWordUtil.WordsDatas = data.Split(','); } catch (Exception ex) { Log.Error(ex); } UINetLoadingComponent.closeNetLoading(); }
public static void Debug(string msg) { if (!NetConfig.getInstance().isFormal) { ETModel.Log.Debug(msg); } }
internal static unsafe bool GetConfigInt(NetConfig type, int value) { int *numPointer = &value; bool flag = SteamNetworkingUtils.Internal.SetConfigValue(type, NetScope.Global, (long)0, NetConfigType.Int32, (IntPtr)numPointer); return(flag); }
/// <summary> /// Load Settings from config. /// </summary> /// <param name="isServer"></param> /// <returns></returns> public static TcpSettings[] LoadSettings(bool isServer) { List <TcpSettings> list = new List <TcpSettings>(); try { System.Configuration.Configuration config = NetConfig.GetConfiguration(); XmlDocument doc = new XmlDocument(); doc.Load(config.FilePath); Netlog.Debug("LoadSettings : " + config.FilePath); string xpath = isServer ? "//TcpServerSettings" : "//TcpClientSettings"; XmlNode root = doc.SelectSingleNode(xpath); foreach (XmlNode n in root.ChildNodes) { if (n.NodeType == XmlNodeType.Comment) { continue; } TcpSettings ps = new TcpSettings(n, isServer); list.Add(ps); } return(list.ToArray()); } catch (Exception ex) { throw ex; } }
public void Open() { NetConfig config = new NetConfig(); config.Host = ServerConfig.Host; config.Port = ServerConfig.Port; config.CertificateFile = ServerConfig.CertificateFile; config.CertificatePassword = ServerConfig.CertificatePassword; if (!string.IsNullOrEmpty(config.CertificateFile)) { config.SSL = true; } config.LittleEndian = false; HttpPacket hp = new HttpPacket(this.ServerConfig.BodySerializer, this.ServerConfig, this); mServer = SocketFactory.CreateTcpServer(config, this, hp); mServer.Name = "FastHttpApi Http Server"; ApiViews.ApiInfoController aic = new ApiViews.ApiInfoController(); aic.HandleFactory = mActionFactory; mActionFactory.Register(ServerConfig, this, aic); if (mAssemblies != null) { foreach (System.Reflection.Assembly assembly in mAssemblies) { mResourceCenter.LoadManifestResource(assembly); } } mResourceCenter.LoadManifestResource(typeof(HttpApiServer).Assembly); mResourceCenter.Path = ServerConfig.StaticResourcePath; mResourceCenter.Debug = ServerConfig.Debug; mResourceCenter.Load(); mServer.Open(); }
protected override void OnStart(string[] args) { if (!OtherConfig.init()) { return; } // 日志 LogUtil.getInstance().start(OtherConfig.s_logPath + "TLJ_PlayServiceLog"); // 全局定时器 GlobalTimer.getInstance().start(); if (!NetConfig.init()) { return; } //log4net.Config.XmlConfigurator.Configure(); //log = LogManager.GetLogger(TAG); //log.Info("日志开启"); m_serverUtil = new HPServerUtil(); m_mySqlServerUtil = new MySqlServerUtil(); LogUtil.getInstance().addDebugLog("服务开启"); // 开启TCP服务组件与客户端通信 m_serverUtil.startTCPService(); // 开启TCP客户端组件与数据库服务器通信 m_mySqlServerUtil.start(); }
internal static unsafe bool SetConfigFloat(NetConfig type, float value) { float *singlePointer = &value; bool flag = SteamNetworkingUtils.Internal.SetConfigValue(type, NetScope.Global, (long)0, NetConfigType.Float, (IntPtr)singlePointer); return(flag); }
// 获取数值表 public void getNetFile() { // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("GetNetEntityFile_hotfix", "getNetFile")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.GetNetEntityFile_hotfix", "getNetFile", null, null); return; } Invoke("onInvoke", 6); // 恢复初始状态 { for (int i = 0; i < m_fileList.Count; i++) { m_fileList[i].m_fileGetState = FileInfo.FileGetState.FileGetState_NoStart; } } // 拉取数值表 { NetLoading.getInstance().Show(); NetConfig.reqNetConfig(); PropData.getInstance().reqNet(); ChatData.getInstance().reqNet(); HuDongData.getInstance().reqNet(); if (SensitiveWordUtil.WordsDatas == null || SensitiveWordUtil.WordsDatas.Length == 0) { SensitiveWordUtil.reqNet(); } VipData.reqNet(); } }
public async Task LoadMember(long projectId) { string url = NetConfig.UrlJoin("project", "member/" + projectId); EmployeeController employeeController = new EmployeeController(); Employees = await employeeController.LoadListFromUrlAsync(url); }
public async void Awake() { await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/chat.json", ChatConfig.getInstance().init); ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>(); ExpressionBtn = rc.Get <GameObject>("ExpressionBtn").GetComponent <Button>(); ShortBtn = rc.Get <GameObject>("ShortBtn").GetComponent <Button>(); Mask = rc.Get <GameObject>("Mask").GetComponent <Button>(); ExceptionTxt = rc.Get <GameObject>("ExceptionTxt").GetComponent <Text>(); ExpressionGrid = ExpressionBtn.transform.Find("Select_Btn/Scroll/ExpressionGrid").gameObject; ShortGrid = ShortBtn.transform.Find("Select_Btn/Scroll/ShortGrid").gameObject; ExpressionBtn.onClick.Add(() => { CreatExpressions(); }); CommonUtil.SetTextFont(this.GetParent <UI>().GameObject); Mask.onClick.Add(() => { CloseOrOpenChatUI(false); }); ShortBtn.onClick.Add(() => { CreateChatItems(); }); ExpressionItem = CommonUtil.getGameObjByBundle(UIType.UIExpression); ChatItem = CommonUtil.getGameObjByBundle(UIType.UIChatItem); isOpen = false; //选中表情包界面 CreatExpressions(); }
public override void ReadConfig(NetConfig config) { //testtext.text = config.ClientHost + config.ClientPort; base.ReadConfig(config); ListenHost = config.ClientHost; ListenPort = int.Parse(config.ClientPort); }
public void netDataDown() { // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("LoginScript_hotfix", "netDataDown")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.LoginScript_hotfix", "netDataDown", null, null); return; } // 拉取数值表 { NetLoading.getInstance().Show(); NetConfig.reqNetConfig(); PropData.getInstance().reqNet(); ChatData.getInstance().reqNet(); HuDongData.getInstance().reqNet(); SensitiveWordUtil.reqNet(); VipData.reqNet(); } if (OtherData.s_isTest) { ToastScript.createToast("这是测试包"); } else { LogUtil.Log("这是正式包"); } }
public Server(NetConfig Config) { this.Config = Config; if (this.Config == null) { this.Config = NetConfig.CreateDefaultServerConfig(); } }
public static void Main(string[] args) { NetConfig config = new NetConfig(); server = ServerFactory.CreateTcpServer <Program>(config); server.Open(); Console.Read(); }
public void Update(float deltaTime) { if (drawOffset.LengthSquared() < 0.01f) { PositionSmoothingFactor = null; } drawOffset = NetConfig.InterpolateSimPositionError(drawOffset, PositionSmoothingFactor); rotationOffset = NetConfig.InterpolateRotationError(rotationOffset); }
public PosInfo ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime, string parentDebugName) { float MaxVel = NetConfig.MaxPhysicsBodyVelocity; float MaxAngularVel = NetConfig.MaxPhysicsBodyAngularVelocity; Vector2 newPosition = SimPosition; float? newRotation = null; bool awake = FarseerBody.Awake; Vector2 newVelocity = LinearVelocity; float? newAngularVelocity = null; newPosition = new Vector2( msg.ReadSingle(), msg.ReadSingle()); awake = msg.ReadBoolean(); bool fixedRotation = msg.ReadBoolean(); if (!fixedRotation) { newRotation = msg.ReadRangedSingle(0.0f, MathHelper.TwoPi, 8); } if (awake) { newVelocity = new Vector2( msg.ReadRangedSingle(-MaxVel, MaxVel, 12), msg.ReadRangedSingle(-MaxVel, MaxVel, 12)); newVelocity = NetConfig.Quantize(newVelocity, -MaxVel, MaxVel, 12); if (!fixedRotation) { newAngularVelocity = msg.ReadRangedSingle(-MaxAngularVel, MaxAngularVel, 8); newAngularVelocity = NetConfig.Quantize(newAngularVelocity.Value, -MaxAngularVel, MaxAngularVel, 8); } } msg.ReadPadBits(); if (!MathUtils.IsValid(newPosition) || !MathUtils.IsValid(newVelocity) || (newRotation.HasValue && !MathUtils.IsValid(newRotation.Value)) || (newAngularVelocity.HasValue && !MathUtils.IsValid(newAngularVelocity.Value))) { string errorMsg = "Received invalid position data for \"" + parentDebugName + "\" (position: " + newPosition + ", rotation: " + (newRotation ?? 0) + ", velocity: " + newVelocity + ", angular velocity: " + (newAngularVelocity ?? 0) + ")"; #if DEBUG DebugConsole.ThrowError(errorMsg); #endif GameAnalyticsManager.AddErrorEventOnce("PhysicsBody.ClientRead:InvalidData" + parentDebugName, GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg); return(null); } return(lastProcessedNetworkState > sendingTime ? null : new PosInfo(newPosition, newRotation, newVelocity, newAngularVelocity, sendingTime)); }
public static void Main(string[] args) { NetConfig config = new NetConfig(); mServer = ServerFactory.CreateTcpServer <Program, SmartRoute.Protocols.Packet>(config); mClient = ServerFactory.CreateTcpClient <Protocols.ClientPacket>("192.168.1.241", 10100); mServer.Open(); Console.Read(); }
/// <summary> /// load then parse project data from web and bind to xaml /// </summary> private async void LoadProjectData() { projectController = new ProjectController(); string url = NetConfig.UrlJoin("project", ""); projects = await projectController.LoadListFromUrlAsync(url); lbProjects.ItemsSource = projects; }
public static void Main(string[] args) { DefaultPacket.Register(typeof(Program)); NetConfig config = new NetConfig(); mServer = ServerFactory.CreateTcpServer <Program, DefaultPacket>(config); mServer.Open(); Console.Read(); }
internal static unsafe int GetConfigInt(NetConfig type) { int num; int num1 = 0; NetConfigType netConfigType = NetConfigType.Int32; int * numPointer = &num1; ulong num2 = (ulong)4; num = (SteamNetworkingUtils.Internal.GetConfigValue(type, NetScope.Global, (long)0, ref netConfigType, (IntPtr)numPointer, ref num2) == NetConfigResult.OK ? num1 : 0); return(num); }
internal static unsafe float GetConfigFloat(NetConfig type) { float single; float single1 = 0f; NetConfigType netConfigType = NetConfigType.Float; float * singlePointer = &single1; ulong num = (ulong)4; single = (SteamNetworkingUtils.Internal.GetConfigValue(type, NetScope.Global, (long)0, ref netConfigType, (IntPtr)singlePointer, ref num) == NetConfigResult.OK ? single1 : 0f); return(single); }
public static void Main(string[] args) { NetConfig config = new NetConfig(); //config.SSL = true; //config.CertificateFile = @"c:\ssltest.pfx"; //config.CertificatePassword = "******"; server = SocketFactory.CreateTcpServer <Program>(config); server.Open(); Console.Write(server); Console.Read(); }
public void AddTest() { using (var db = GetContext()) { db.DbSet.Select <NetConfig>() .Where(nc => nc.ConfigName == "»ª¹¤"); NetConfig netConfig = db.Single <NetConfig>(); netConfig.ConfigName = "»ª¹¤2"; db.DbSet.Insert(netConfig); db.Execute(); } }
private NetConfig CreateServerConfig() { ServerConfig = new NetConfig(); ServerConfig.SetMaxBackLogConnections(MAXIMUM_BACKLOG); ServerConfig.SetMaxConnections(MAXIMUM_CONNECTIONS); ServerConfig.SetMaxMessageSize(MESSAGE_SIZE); ServerConfig.SetBufferSize(BUFFER_SIZE); ServerConfig.SetHeaderSize(HEADER_SIZE); ServerConfig.SetEnableKeepAlive(false); ServerConfig.SetPort(1669); return(ServerConfig); }
public async void Awake() { // 获取配置文件 { string fileName = "otherConfig-" + PlatformHelper.GetVersionName() + ".json"; await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/" + fileName, OtherConfig.getInstance().init); } ToastScript.clear(); Instance = this; initData(); CommonUtil.SetTextFont(panel_start.transform.parent.gameObject); }
public async void onClickGetPhoneCode() { if (inputField_Phone.text.CompareTo("") == 0) { ToastScript.createToast("请输入手机号"); return; } if (!VerifyRuleUtil.CheckPhone(inputField_Phone.text)) { ToastScript.createToast("请输入正确的手机号"); return; } btn_yanzhengma.transform.localScale = Vector3.zero; text_yanzhengmadaojishi.transform.localScale = new Vector3(1, 1, 1); UINetLoadingComponent.showNetLoading(); Session sessionWrap = null; try { //IPEndPoint connetEndPoint = NetworkHelper.ToIPEndPoint(GlobalConfigComponent.Instance.GlobalProto.Address); IPEndPoint connetEndPoint = ToIPEndPointWithYuMing(NetConfig.getInstance().getServerPort()); ETModel.Session session = ETModel.Game.Scene.GetComponent <NetOuterComponent>().Create(connetEndPoint); sessionWrap = ComponentFactory.Create <Session, ETModel.Session>(session); R2C_SendSms r2CData = (R2C_SendSms)await sessionWrap.Call(new C2R_SendSms() { Phone = inputField_Phone.text }); UINetLoadingComponent.closeNetLoading(); if (r2CData.Error != ErrorCode.ERR_Success) { ToastScript.createToast(r2CData.Message); } sessionWrap.Dispose(); startPhoneCodeTimer(); } catch (Exception e) { sessionWrap?.Dispose(); Log.Error(e); } }
public static void Main(string[] args) { NetConfig config = new NetConfig(); HttpPacket packet = new HttpPacket(new StringSerializer()); server = SocketFactory.CreateTcpServer(config, new Program(), packet); server.Open(); while (true) { Console.Write(server); System.Threading.Thread.Sleep(1000); } Console.Read(); }
public void Start(NetConfig config) //START SERVER WITH A CONFIG { //SPAWN A THREAD FOR THE NEW CONNECTION CHECKING FUNCTION. Thread checkThread = new Thread(new ParameterizedThreadStart(ConnectionCheckingThread)); checkThread.IsBackground = true; checkThread.Start(config.Timeout); //END ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); ServerSocket.IOControl(SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 }, null); //Fixs the Exception : An existing connection was forcibly closed by the remote host. ServerSocket.Bind(new IPEndPoint(IPAddress.Any, config.Port)); Connection = new NetConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), config.Port)); EndPoint remoteSender = new IPEndPoint(IPAddress.Any, 0); try { ServerSocket.BeginReceiveFrom(DATA, 0, DATA.Length,SocketFlags.None, ref remoteSender, Handle_Receive, ServerSocket); } catch(Exception e) { #if DEBUG_OUTPUT Console.WriteLine("Exception: in BeginReceiveFrom: " + e.Message); #endif } }
public virtual object Create (object parent, object configContext, XmlNode section) { NetConfig config = new NetConfig (); #if (XML_DEP) if (section.Attributes != null && section.Attributes.Count != 0) HandlersUtil.ThrowException ("Unrecognized attribute", section); XmlNodeList reqHandlers = section.ChildNodes; foreach (XmlNode child in reqHandlers) { XmlNodeType ntype = child.NodeType; if (ntype == XmlNodeType.Whitespace || ntype == XmlNodeType.Comment) continue; if (ntype != XmlNodeType.Element) HandlersUtil.ThrowException ("Only elements allowed", child); string name = child.Name; if (name == "ipv6") { string enabled = HandlersUtil.ExtractAttributeValue ("enabled", child, false); if (child.Attributes != null && child.Attributes.Count != 0) HandlersUtil.ThrowException ("Unrecognized attribute", child); if (enabled == "true") config.ipv6Enabled = true; else if (enabled != "false") HandlersUtil.ThrowException ("Invalid boolean value", child); continue; } if (name == "httpWebRequest") { string max = HandlersUtil.ExtractAttributeValue ("maximumResponseHeadersLength", child, true); // this one is just ignored HandlersUtil.ExtractAttributeValue ("useUnsafeHeaderParsing", child, true); if (child.Attributes != null && child.Attributes.Count != 0) HandlersUtil.ThrowException ("Unrecognized attribute", child); try { if (max != null) { int val = Int32.Parse (max.Trim ()); if (val < -1) HandlersUtil.ThrowException ("Must be -1 or >= 0", child); config.MaxResponseHeadersLength = val; } } catch { HandlersUtil.ThrowException ("Invalid int value", child); } continue; } HandlersUtil.ThrowException ("Unexpected element", child); } #endif return config; }