public void Connect() { string playerName = GameObject.Find("Name Field").GetComponent <InputField>().text; connectToAddress = GameObject.Find("Address Field").GetComponent <InputField>().text; if (playerName == "") { Debug.LogWarning("You must have a name!"); playerName = PlayerName.GetName(); } PlayerName.SetName(playerName); NetworkTransport.Init(); ConnectionConfig cc = new ConnectionConfig(); reliableChannel = cc.AddChannel(QosType.Reliable); unreliableChannel = cc.AddChannel(QosType.Unreliable); HostTopology topo = new HostTopology(cc, MAX_CONNECTION); hostId = NetworkTransport.AddHost(topo, 0); connectionId = NetworkTransport.Connect(hostId, connectToAddress, port, 0, out error); connectionTime = Time.time; isConnected = true; packMan.ClearPacks(); Debug.Log("Started Client! : Error " + error + " : Port " + port); }
public IEnumerator IsConnectedPropertyWorksOnDifferentClientsTest() { NetworkClient.ShutdownAll(); NetworkServer.Reset(); ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); remoteClient = new NetworkClient(); if (!remoteClient.Configure(config, 10)) { Assert.Fail("Client configure failed"); } remoteClient.RegisterHandler(MsgType.Connect, OnClientConnected); Assert.IsFalse(remoteClient.isConnected); int retries = 0; while (!NetworkServer.Listen("127.0.0.1", ++kListenPort)) { Assert.IsTrue(retries++ < 10, "Couldn't Listen for more than 10 retries"); } remoteClient.Connect("127.0.0.1", kListenPort); while (!isTestDone) { yield return(null); } }
void Awake() { self = this; Application.runInBackground = true; NetworkTransport.Init(); GlobalConfig gConfig = new GlobalConfig(); gConfig.MaxPacketSize = 500; NetworkTransport.Init(gConfig); ConnectionConfig config = new ConnectionConfig(); reliableCHN = config.AddChannel(QosType.AllCostDelivery); unreliableCHN = config.AddChannel(QosType.StateUpdate); HostTopology topology = new HostTopology(config, 10); // max connections socketId = NetworkTransport.AddHost(topology, clientPort); Debug.Log("Socket Open. SocketId is: " + socketId); recvBuffer = new byte[1024]; synchronizedComponents = new Dictionary <int, ReplicatedProperties>(); sendBuffer = new SerializedBuffer[2]; sendBuffer[0] = new SerializedBuffer(); sendBuffer[1] = new SerializedBuffer(); }
public void init(Client_Engine eng) { e = eng; ConnectionConfig conf = new ConnectionConfig(); conf.AddChannel(QosType.ReliableFragmented); conf.AddChannel(QosType.UnreliableFragmented); conf.ConnectTimeout = 1000; conf.MaxConnectionAttempt = 5; Client = new NetworkClient(); Client.Configure(conf, 1); Client.RegisterHandler(MsgType.Connect, net_onServerConnect); Client.RegisterHandler(MsgType.Error, net_onError); Client.RegisterHandler(MsgType.Disconnect, net_onServerDisconnect); Client.RegisterHandler(OPCodes.S2GC_AskLoginResponse, net_onAskLoginResponse); Client.RegisterHandler(OPCodes.S2GC_AskCharacterListResponse, net_onCharacterListResponse); Client.RegisterHandler(OPCodes.S2GC_AskCreateCharacterResponse, net_onAskCreateCharacterResponse); Client.RegisterHandler(OPCodes.S2GC_AskDeleteCharacterResponse, net_onAskDeleteCharacterResponse); Client.RegisterHandler(OPCodes.S2GC_AskEnterWorldResponse, net_onAskEnterWorldResponse); Client.RegisterHandler(OPCodes.S2GC_ClientPlayerSpawn, net_onClientSelfSpawn); Client.RegisterHandler(OPCodes.S2GC_OtherClientSpawn, net_onOtherClientSpawn); Client.RegisterHandler(OPCodes.S2GC_FullClientList, net_onFullClientList); Client.RegisterHandler(OPCodes.S2GC_UpdatePlayerStates, net_onUpdatePlayerStates); Client.RegisterHandler(OPCodes.S2GC_UpdateNPCStates, net_onUpdateNPCStates); Client.RegisterHandler(OPCodes.S2GC_FullNPCList, net_onFullNPCList); Client.RegisterHandler(OPCodes.S2GC_UpdateEntityStates, net_onUpdateEnityStates); Client.RegisterHandler(OPCodes.S2GC_OtherClientDisconnect, net_onOtherClientDisconnect); Client.RegisterHandler(OPCodes.S2GC_CastSpell, net_onSpellCast); Client.RegisterHandler(OPCodes.GC2S2GC_ChatMessage, net_onChatMessage); Client.RegisterHandler(OPCodes.S2GC_PlayerEnterCombat, net_onEnterCombat); Client.RegisterHandler(OPCodes.S2GC_PlayerExitCombat, net_onExitCombat); Client.RegisterHandler(OPCodes.S2GC_GiveQuest, net_onGivenQuest); Client.RegisterHandler(OPCodes.S2GC_UpdateQuest, net_onUpdateQuests); }
public void ConnectTo(Host host) { Debug.Log("Connecting" + host == null); connectedHost = host; //Debug.Log(host != null); if (hostId != -1) { NetworkTransport.RemoveHost(hostId); } ConnectionConfig cc = new ConnectionConfig(); reliableChannel = cc.AddChannel(QosType.Reliable); unreliableChannel = cc.AddChannel(QosType.Unreliable); HostTopology topo = new HostTopology(cc, MAX_CONNECTION); hostId = NetworkTransport.AddHost(topo, 0); if (hostId == -1) { Debug.LogError("NetworkDiscovery StartAsClient - addHost failed"); return; } connectionId = NetworkTransport.Connect(hostId, connectedHost.ip, connectedHost.port, 0, out error); //isConnected = true; timer = Time.time; requestingConnection = true; //lobbySearchCanvas.transform.Find("FindHostBtn").gameObject.SetActive(false); //lobbySearchCanvas.transform.Find("StopSearchBtn").gameObject.SetActive(false); //Debug.Log("connected ot host"); //findingHosts = false; //Debug.Log(connectionId); }
public void Connect() { // This method connects the client to the server if (isAttemptingConnection == false && isConnected == false) // Make sure we're not already connected and we're not already attempting to connect to server { Debug.Log("Attempting to connect to server..."); playerName = inputField_PlayerName.text; //ipAddressServer = "174.138.46.138"; // TODO: probably shouldn't hardcode this? ipAddressServer = "127.0.0.1"; // TODO: probably shouldn't hardcode this? NetworkTransport.Init(); // Initialize NetworkTransport ConnectionConfig newConnectionConfig = new ConnectionConfig(); reliableChannel = newConnectionConfig.AddChannel(QosType.Reliable); unreliableChannel = newConnectionConfig.AddChannel(QosType.Unreliable); reliableFragmentedSequencedChannel = newConnectionConfig.AddChannel(QosType.ReliableFragmentedSequenced); reliableSequencedChannel = newConnectionConfig.AddChannel(QosType.ReliableSequenced); HostTopology topo = new HostTopology(newConnectionConfig, MAX_CONNECTION); // Setup topology hostId = NetworkTransport.AddHost(topo, 0); // Gets the Id for the host Debug.Log("Connecting with Ip: " + ipAddressServer + " port: " + port); connectionId = NetworkTransport.Connect(hostId, ipAddressServer, port, 0, out error); // Gets the Id for the connection (not the same as ourClientId) isAttemptingConnection = true; } }
void PrepareForConnect(bool usePlatformSpecificProtocols) { SetActive(true); RegisterSystemHandlers(false); if (m_HostTopology == null) { var config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); config.UsePlatformSpecificProtocols = usePlatformSpecificProtocols; m_HostTopology = new HostTopology(config, 8); } if (m_UseSimulator) { int minTimeout = (m_SimulatedLatency / 3) - 1; if (minTimeout < 1) { minTimeout = 1; } int maxTimeout = m_SimulatedLatency * 3; if (LogFilter.logDebug) { Debug.Log("AddHost Using Simulator " + minTimeout + "/" + maxTimeout); } m_ClientId = NetworkManager.activeTransport.AddHostWithSimulator(m_HostTopology, minTimeout, maxTimeout, m_HostPort); } else { m_ClientId = NetworkManager.activeTransport.AddHost(m_HostTopology, m_HostPort, null); } }
public void Connect() { // Does the player have a name? string pName = GameObject.Find("NameInput").GetComponent <InputField>().text; if (pName == "") { Debug.Log("You must enter a name!"); return; } playerName = pName; NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); reliableChannel = config.AddChannel(QosType.Reliable); unreliableChannel = config.AddChannel(QosType.Unreliable); HostTopology topology = new HostTopology(config, MAX_CONNECTION); hostID = NetworkTransport.AddHost(topology); connectionID = NetworkTransport.Connect(hostID, "0.0.0.0", port, 0, out error); connectionTime = Time.time; isConnected = true; }
private HostTopology getTopology(int maxConnections) { var config = new ConnectionConfig(); _eventChannelId = config.AddChannel(QosType.Reliable); _deltaChannelId = config.AddChannel(QosType.Unreliable); return(new HostTopology(config, maxConnections)); }
public UNetCommsNetwork() { var config = new ConnectionConfig(); _voiceChannel = config.AddChannel(QosType.Unreliable); _sysChannel = config.AddChannel(QosType.ReliableSequenced); _topology = new HostTopology(config, MaxConnections); }
// Token: 0x060000FC RID: 252 RVA: 0x00006CA0 File Offset: 0x00004EA0 public static ConnectionConfig CreateDefaultConnectionConfig() { ConnectionConfig connectionConfig = new ConnectionConfig(); connectionConfig.AddChannel(QosType.Reliable); connectionConfig.AddChannel(0); return(connectionConfig); }
public void InitNetwork() { NetworkTransport.Init(networkConfiguration); connectionConfig.Channels.Clear(); reliableChannel = connectionConfig.AddChannel(QosType.Reliable); unreliableChannel = connectionConfig.AddChannel(QosType.Unreliable); }
public static ConnectionConfig CreateDefaultConnectionConfig() { var config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); return(config); }
void Awake() { // create global config if none passed // -> settings copied from uMMORPG configuration for best results if (globalConfig == null) { globalConfig = new GlobalConfig { ReactorModel = ReactorModel.SelectReactor, ThreadAwakeTimeout = 1, ReactorMaximumSentMessages = 4096, ReactorMaximumReceivedMessages = 4096, MaxPacketSize = 2000, MaxHosts = 16, ThreadPoolSize = 3, MinTimerTimeout = 1, MaxTimerTimeout = 12000 }; } NetworkTransport.Init(globalConfig); // create connection config if none passed // -> settings copied from uMMORPG configuration for best results if (connectionConfig == null) { connectionConfig = new ConnectionConfig { PacketSize = 1500, FragmentSize = 500, ResendTimeout = 1200, DisconnectTimeout = 6000, ConnectTimeout = 6000, MinUpdateTimeout = 1, PingTimeout = 2000, ReducedPingTimeout = 100, AllCostTimeout = 20, NetworkDropThreshold = 80, OverflowDropThreshold = 80, MaxConnectionAttempt = 10, AckDelay = 33, SendDelay = 10, MaxCombinedReliableMessageSize = 100, MaxCombinedReliableMessageCount = 10, MaxSentMessageQueueSize = 512, AcksType = ConnectionAcksType.Acks128, InitialBandwidth = 0, BandwidthPeakFactor = 2, WebSocketReceiveBufferMaxSize = 0, UdpSocketReceiveBufferMaxSize = 0 }; // channel 0 is reliable fragmented sequenced connectionConfig.AddChannel(QosType.ReliableFragmentedSequenced); // channel 1 is unreliable connectionConfig.AddChannel(QosType.Unreliable); } Debug.Log("LLAPITransport initialized!"); }
public void StartDedicatedCustom() { ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); StartServer(config, maxPlayers); }
public void StartJoinCustom() { ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.ReliableSequenced); config.AddChannel(QosType.Unreliable); StartClient(null, config); }
// Client/Server function that initializes the network topology void CLIENT_SERVER_set_network_topology() { port = 8888; /// Global Config defines global paramters for network library. GlobalConfig global_configuration = new GlobalConfig(); global_configuration.ReactorModel = ReactorModel.SelectReactor; global_configuration.ThreadAwakeTimeout = 10; /// Add a channel to send and recieve /// Build channel configuration ConnectionConfig connection_configuration = new ConnectionConfig(); connection_configuration.PingTimeout = 50000; connection_configuration.DisconnectTimeout = 50000; unreliable_channel = connection_configuration.AddChannel(QosType.UnreliableSequenced); reliable_channel = connection_configuration.AddChannel(QosType.ReliableSequenced); /// Create Network Topology for host configuration /// This topology defines: /// (1) how many connection with default config will be supported/ /// (2) what will be special connections (connections with config different from default). HostTopology host_topology; if (is_server == true) { int max_connections = 10; host_topology = new HostTopology(connection_configuration, max_connections); } else { host_topology = new HostTopology(connection_configuration, 1); } /// Initializes the NetworkTransport. /// Should be called before any other operations on the NetworkTransport are done. NetworkTransport.Init(); // Open sockets for server and client if (is_server == true) { socket_ID = NetworkTransport.AddHost(host_topology, port); } else { socket_ID = NetworkTransport.AddHost(host_topology); } if (socket_ID < 0) { Debug.Log("Socket creation failed!"); } }
public LLAPITransport(GlobalConfig globalConfig = null, ConnectionConfig connectionConfig = null) { // create global config if none passed // -> settings copied from uMMORPG configuration for best results if (globalConfig == null) { globalConfig = new GlobalConfig(); globalConfig.ReactorModel = ReactorModel.SelectReactor; globalConfig.ThreadAwakeTimeout = 1; globalConfig.ReactorMaximumSentMessages = 4096; globalConfig.ReactorMaximumReceivedMessages = 4096; globalConfig.MaxPacketSize = 2000; globalConfig.MaxHosts = 16; globalConfig.ThreadPoolSize = 3; globalConfig.MinTimerTimeout = 1; globalConfig.MaxTimerTimeout = 12000; } this.globalConfig = globalConfig; NetworkTransport.Init(globalConfig); // create connection config if none passed // -> settings copied from uMMORPG configuration for best results if (connectionConfig == null) { connectionConfig = new ConnectionConfig(); connectionConfig.PacketSize = 1500; connectionConfig.FragmentSize = 500; connectionConfig.ResendTimeout = 1200; connectionConfig.DisconnectTimeout = 6000; connectionConfig.ConnectTimeout = 6000; connectionConfig.MinUpdateTimeout = 1; connectionConfig.PingTimeout = 2000; connectionConfig.ReducedPingTimeout = 100; connectionConfig.AllCostTimeout = 20; connectionConfig.NetworkDropThreshold = 80; connectionConfig.OverflowDropThreshold = 80; connectionConfig.MaxConnectionAttempt = 10; connectionConfig.AckDelay = 33; connectionConfig.SendDelay = 10; connectionConfig.MaxCombinedReliableMessageSize = 100; connectionConfig.MaxCombinedReliableMessageCount = 10; connectionConfig.MaxSentMessageQueueSize = 512; connectionConfig.AcksType = ConnectionAcksType.Acks128; connectionConfig.InitialBandwidth = 0; connectionConfig.BandwidthPeakFactor = 2; connectionConfig.WebSocketReceiveBufferMaxSize = 0; connectionConfig.UdpSocketReceiveBufferMaxSize = 0; // channel 0 is reliable fragmented sequenced connectionConfig.AddChannel(QosType.ReliableFragmentedSequenced); // channel 1 is unreliable connectionConfig.AddChannel(QosType.Unreliable); } this.connectionConfig = connectionConfig; Debug.Log("LLAPITransport initialized!"); }
void SetupConfig() { GlobalConfig globalConfig = new GlobalConfig(); connectionConfig = new ConnectionConfig(); reliableSequencedChannel = connectionConfig.AddChannel(QosType.ReliableSequenced); reliableChannel = connectionConfig.AddChannel(QosType.Reliable); unreliableChannel = connectionConfig.AddChannel(QosType.Unreliable); NetworkTransport.Init(globalConfig); }
static BarebonesTopology() { var config = new ConnectionConfig(); ReliableChannel = config.AddChannel(QosType.Reliable); UnreliableChannel = config.AddChannel(QosType.Unreliable); ReliableSequencedChannel = config.AddChannel(QosType.ReliableSequenced); Topology = new HostTopology(config, 5000); }
void BaseInit() { gConfig = new GlobalConfig(); gConfig.MaxPacketSize = 1500; NetworkTransport.Init(gConfig); config = new ConnectionConfig(); myReliableChannelId = config.AddChannel(QosType.Reliable); myUnreliableChannelId = config.AddChannel(QosType.Unreliable); topology = new HostTopology(config, 10); }
private void Setup() { var config = new ConnectionConfig(); config.AddChannel(QosType.ReliableFragmented); config.AddChannel(QosType.UnreliableFragmented); NetworkServer.Configure(config, 2); Application.runInBackground = true; }
private bool StartServer(ConnectionConfig config, int maxConnections) { InitializeSingleton(); OnStartServer(); if (runInBackground) { Application.runInBackground = true; } QNetworkCRC.scriptCRCCheck = scriptCRCCheck; QNetworkServer.useWebSockets = useWebSockets; if (m_GlobalConfig != null) { NetworkTransport.Init(m_GlobalConfig); } if (customConfig && m_ConnectionConfig != null && config == null) { m_ConnectionConfig.Channels.Clear(); foreach (var channel in channels) { m_ConnectionConfig.AddChannel(channel); } QNetworkServer.Configure(m_ConnectionConfig, this.maxConnections); } if (config != null) { QNetworkServer.Configure(config, maxConnections); } if (serverBindToIP && !string.IsNullOrEmpty(serverBindAddress)) { if (!QNetworkServer.Listen(serverBindAddress, networkPort)) { QLog.FatalError($"StartServer listen on {serverBindAddress} failed."); return(false); } } else if (!QNetworkServer.Listen(networkPort)) { QLog.FatalError("StartServer listen failed."); return(false); } RegisterServerMessages(); QLog.Log($"NetworkManager StartServer port:{networkPort}"); isNetworkActive = true; var name = SceneManager.GetSceneAt(0).name; if (!string.IsNullOrEmpty(onlineScene) && onlineScene != name && onlineScene != offlineScene) { ServerChangeScene(onlineScene); } else { QNetworkServer.SpawnObjects(); } return(true); }
private void Start() { //get ip address since we aren't using NetworkManager and cannot use that singleton: ipAddress = "::ffff:" + IPManager.GetIP(ADDRESSFAM.IPv4); //setup: broadcastPort = broadcastingPort; Initialize(); StartAsClient(); //configurations: _client = new NetworkClient(); ConnectionConfig config = new ConnectionConfig(); PrimaryChannel = config.AddChannel(primaryQualityOfService); SecondaryChannel = config.AddChannel(secondaryQualityOfService); config.InitialBandwidth = initialBandwidth; HostTopology topology = new HostTopology(config, 1); _client.Configure(topology); //event hooks: _client.RegisterHandler(MsgType.Error, HandleNetworkError); _client.RegisterHandler(MsgType.Connect, HandleConnected); _client.RegisterHandler(MsgType.Disconnect, HandleDisconnected); _client.RegisterHandler((short)NetworkMsg.FloatMsg, HandleFloat); _client.RegisterHandler((short)NetworkMsg.FloatArrayMsg, HandleFloatArray); _client.RegisterHandler((short)NetworkMsg.IntMsg, HandleInt); _client.RegisterHandler((short)NetworkMsg.IntArrayMsg, HandleIntArray); _client.RegisterHandler((short)NetworkMsg.Vector2Msg, HandleVector2); _client.RegisterHandler((short)NetworkMsg.Vector2ArrayMsg, HandleVector2Array); _client.RegisterHandler((short)NetworkMsg.Vector3Msg, HandleVector3); _client.RegisterHandler((short)NetworkMsg.Vector3ArrayMsg, HandleVector3Array); _client.RegisterHandler((short)NetworkMsg.QuaternionMsg, HandleQuaternion); _client.RegisterHandler((short)NetworkMsg.QuaternionArrayMsg, HandleQuaternionArray); _client.RegisterHandler((short)NetworkMsg.Vector4Msg, HandleVector4); _client.RegisterHandler((short)NetworkMsg.Vector4ArrayMsg, HandleVector4Array); _client.RegisterHandler((short)NetworkMsg.RectMsg, HandleRect); _client.RegisterHandler((short)NetworkMsg.RectArrayMsg, HandleRectArray); _client.RegisterHandler((short)NetworkMsg.StringMsg, HandleString); _client.RegisterHandler((short)NetworkMsg.StringArrayMsg, HandleStringArray); _client.RegisterHandler((short)NetworkMsg.ByteMsg, HandleByte); _client.RegisterHandler((short)NetworkMsg.ByteArrayMsg, HandleByteArray); _client.RegisterHandler((short)NetworkMsg.ColorMsg, HandleColor); _client.RegisterHandler((short)NetworkMsg.ColorArrayMsg, HandleColorArray); _client.RegisterHandler((short)NetworkMsg.Color32Msg, HandleColor32); _client.RegisterHandler((short)NetworkMsg.Color32ArrayMsg, HandleColor32Array); _client.RegisterHandler((short)NetworkMsg.BoolMsg, HandleBool); _client.RegisterHandler((short)NetworkMsg.BoolArrayMsg, HandleBoolArray); _client.RegisterHandler((short)NetworkMsg.Matrix4x4Msg, HandleMatrix4x4); _client.RegisterHandler((short)NetworkMsg.Matrix4x4ArrayMsg, HandleMatrix4x4Array); }
private void Start() { NetworkTransport.Init(); ConnectionConfig cc = new ConnectionConfig(); reliableChannel = cc.AddChannel(QosType.Reliable); unreliabeChannel = cc.AddChannel(QosType.Unreliable); HostTopology ht = new HostTopology(cc, max_players); hostID = NetworkTransport.AddHost(ht, port, null); }
protected virtual void Initialize() { NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); m_reliableChannel = config.AddChannel(QosType.Reliable); m_unreliableChannel = config.AddChannel(QosType.Unreliable); m_unreliableStateUpdateChannel = config.AddChannel(QosType.StateUpdate); m_hostTopology = new HostTopology(config, 10); }
// Use this for initialization void Start() { NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); reiliableChannelId = config.AddChannel(QosType.Reliable); unreliableChannelId = config.AddChannel(QosType.Unreliable); HostTopology topology = new HostTopology(config, 10); localHostId = NetworkTransport.AddHost(topology, 8888); }
void OnValidate() { // add connectionconfig channels if none if (connectionConfig.Channels.Count == 0) { // channel 0 is reliable fragmented sequenced connectionConfig.AddChannel(QosType.ReliableFragmentedSequenced); // channel 1 is unreliable connectionConfig.AddChannel(QosType.Unreliable); } }
void InitNetwork() { NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); ReliableSequencedChannelId = config.AddChannel(QosType.ReliableSequenced); ReliableChannelId = config.AddChannel(QosType.Reliable); UnreliableChannelId = config.AddChannel(QosType.Unreliable); HostTopology topology = new HostTopology(config, MaxConnections); socketId = NetworkTransport.AddHost(topology, ServerPort); }
/// <summary> /// Initialize the server. It cannot be used before this is called. /// </summary> public void Init() { NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); reliableChannelId = config.AddChannel(QosType.Reliable); stateUpdateChannelId = config.AddChannel(QosType.StateUpdate); HostTopology topology = new HostTopology(config, MAX_CONNECTIONS); hostId = NetworkTransport.AddHost(topology, SERVER_PORT); isInit = true; }