public void FromBin (NetSocket.ByteArray bin) { for (uint i = 0; i < (uint)ECharCityLimit.MAX_CHAR_BIN_CITY_COUNT; ++i) { city [i] = new twp.app.unit.CityData (); city [i].FromBin (bin); } }
/// <summary> /// 断开连接 /// </summary> public override void DisConnect() { try { Connected = false; if (NetSocket == null) { return; } OnDisConnect?.Invoke(this); } catch { } try { SendParser.Clear(); RecvParser.Clear(); NetSocket.Close(); NetSocket.Dispose(); NetSocket = null; this.inArgs.Dispose(); this.outArgs.Dispose(); } catch { } }
void Awake() { socket = GetComponent <NetSocket>(); socket.RegisterRpcListener(this); socket.Events.OnClientDisconnected += EndSession; }
public NetTcpWorker(string ip, ushort port) { recvQueue = new Queue <NetMsgBase>(); sendQueue = new Queue <NetMsgBase>(); clientSocket = new NetSocket(); clientSocket.AsynConnect(ip, port, ConnectCallBack, ReceiveCallBack); }
public void DoDisconnect() { if (sendAsyncEvent != null) { sendAsyncEvent.Completed -= OnHandleSocketEvent; sendAsyncEvent = null; } if (receiveAsyncEvent != null) { receiveAsyncEvent.Completed -= OnHandleSocketEvent; receiveAsyncEvent = null; } lock (cachedWillSendMessageLocker) { cachedWillSendMessages.Clear(); } if (IsConnected) { try { NetSocket.Shutdown(SocketShutdown.Both); }catch (Exception e) { }finally { NetSocket.Close(); } } NetSocket = null; }
public void AddSocket(NetSocket ns) { lock (typeof(NetManager)) { m_Sockets[ns.GetSocket()] = ns; } }
public override void DoConnect(string ip, int port) { if (NetSocket != null) { if (!IsConnected) { try { IPAddress ipAddress = IPAddress.Parse(ip); SocketAsyncEventArgs connectAsyncEvent = new SocketAsyncEventArgs() { RemoteEndPoint = new IPEndPoint(ipAddress, port), UserToken = NetSocket, }; connectAsyncEvent.Completed += OnHandleSocketEvent; OnSessionOperation(NetworkSessionOperation.Connecting); NetSocket.ConnectAsync(connectAsyncEvent); }catch (Exception e) { } } } }
public Network() { Contexts = new List<WebSocketContext>(); Net = new NetSocket(Log.Reporter); ReceivedPackets = new List<ReceivedPacket>(); Users = new Dictionary<WebSocketContext, long>(); }
public NetWorkToSever(string ip, ushort port) { recvMsgPool = new Queue <NetMsgBase>(); sendMsgPool = new Queue <NetMsgBase>(); clientSocket = new NetSocket(); clientSocket.AsynConnect(ip, port, AsysnConnectCallBack, AsysnRecvCallBack); }
private void Awake() { socket = GetComponent<NetSocket>(); //database = GetComponent<StreamDatabaseServer>(); socket.RegisterRpcListener(this); socket.Events.OnClientDisconnected += EndSession; }
public void FromBin(NetSocket.ByteArray bin) { bin.Get_(out pos.x); bin.Get_(out pos.y); bin.Get_(out scene_type_idx); bin.Get_(out scene_obj_idx); }
private void Awake() { socket = GetComponent <NetSocket>(); //database = GetComponent<StreamDatabaseServer>(); socket.RegisterRpcListener(this); socket.Events.OnClientDisconnected += EndSession; }
public new void FromBin(NetSocket.ByteArray bin) { base.FromBin(bin); int result_;bin.Get_(out result_);result = (Result)result_; bin.Get_(out ss_idx); bin.Get_(out char_idx); }
void Awake() { socket = GetComponent<NetSocket>(); socket.RegisterRpcListener(this); socket.Events.OnFailedToConnect += ConnectionFailed; socket.Events.OnConnectedToServer += ConnectedToZone; }
/// <summary> /// Initialize object, open socket. /// </summary> /// <param name="endPoint">NTP Server endpoint</param> /// <param name="onRequestComplete">callback (called from other thread!)</param> private NtpRequest(IPEndPoint endPoint, Action <NtpPacket> onRequestComplete) { _ntpEndPoint = endPoint; _onRequestComplete = onRequestComplete; // Create and start socket _socket = new NetSocket(this); _socket.Bind(IPAddress.Any, IPAddress.IPv6Any, 0, false, true); }
/// <summary> /// Sends the <see cref="NetMessage"/> to the specified <see cref="NetSocket"/>. /// </summary> public static void SendMessage(NetSocket socket, byte[] sessionId, NetMessage message) { if (sessionId == null) { throw new ArgumentNullException("sessionId"); } NetMessaging.Send(socket, message, sessionId); }
/// <summary> /// Sends a <see cref="LoginClientFailedMessage"/> to the specified server. /// </summary> internal void SendLoginClientFailedMessage(int errorCode, byte[] sessionId, NetSocket socket, string reason = null, int remainingTime = -1) { LoginClientFailedMessage message = new LoginClientFailedMessage(); message.SetErrorCode(errorCode); message.SetReason(reason); message.SetRemainingTime(remainingTime); NetMessageManager.SendMessage(socket, sessionId, message); }
public void Bind(int port, string host) { Address = NetAddress.Resolve(port, host, Options.IPv4Only); Socket = new NetSocket(Address, BufferPool, SocketArgPool); Socket.OnAccepted = HandleAccept; Socket.Listen(Options.MaxAccept); OnListen(this); StartAccept(); }
void OnNetStatus(NetSocket net, int status) { if (status == NetSocket.NetStatus.Connected) { Debug.Log("连接上server"); ReqHearbeat(); ReqLogin(); } }
private static void ConnectCB(IAsyncResult ar) { NetSocket obj = (NetSocket)ar.AsyncState; obj.status = CONNECTED; Debug.Log("Connect:" + obj.s.Connected); obj.doRecv(); return; }
private void Awake() { Socket = GetComponent<NetSocket>(); ViewManager = GetComponent<NetViewManager>(); Socket.RegisterRpcListener(this); Socket.Events.OnPeerConnected += PeerConnected; Socket.Events.OnPeerDisconnected += PeerDisconnected; Socket.Events.OnClientConnected += ClientConnected; }
public void FromBin(NetSocket.ByteArray bin) { bin.Get_ (out quest_flags); bin.Get_ (out combat_flags); bin.Get_ (out refresh_pub); bin.Get_ (out refresh_smith_shop); bin.Get_ (out guide_flags); bin.Get_ (out role_event_point); }
public new void FromBin(NetSocket.ByteArray bin) { base.FromBin(bin); // int e_result__; bin.Get_(out e_result__); e_result = (e_result_) e_result__; // bin.Get_(out charidx_created); }
void Awake() { socket = GetComponent <NetSocket>(); socket.RegisterRpcListener(this); socket.Events.OnPeerConnected += Connected; if (!ActAsServer) { MakeBenchData(); } }
public static void clear() { mapData.Clear(); if (null != socket) { socket.RemoveListeners(); socket.Close(); socket = null; } }
private void OnSocketEvent(NetSocket socket, Status status) { bool quiting = (socket as Connection).Quiting; var id = (ConnectionID)socket.ID; if (NetworkStatusChangeEvent != null && !quiting) { NetworkStatusChangeEvent(id, status); } }
public new void FromBin(NetSocket.ByteArray bin) { base.FromBin (bin); bin.Get_ (out param); for(uint i = 0; i < yw.YwEncrypt.LIMIT_KEY_LENGTH; ++i) { bin.Get_ (out key[i]); } }
public EncryptInfo(NetSocket.ByteArray bin) { // 跳过两个字节 bin.Move (NetSocket.CSocketManager.headerLen); bin.Get_ (out param); for (uint i = 0; i < yw.YwEncrypt.LIMIT_KEY_LENGTH; ++i) { bin.Get_ (out key [i]); } }
void Start() { socket = Client.instance.Socket; serverIp = Client.instance.ServerIp; socket.RegisterRpcListener(this); socket.Events.OnConnectedToServer += ConnectedToServer; socket.Events.OnSocketStart += ConnectToLoginServer; socket.Events.OnFailedToConnect += ConnectFailed; socket.Events.OnDisconnectedFromServer += DisconnectedFromServer; }
internal NetConnection(bool isServer, bool isPeer, NetSocket socket, IPEndPoint endpoint, uint id = 0) { IsServer = isServer; IsPeer = isPeer; Socket = socket; Endpoint = endpoint; Id = id; Unreliable = new NetChannelUnreliable(this); Reliable = new NetChannelReliable(this); LastReceiveTime = LastSendTime = Created = NetTime.Milliseconds(); AddToGroup(0); }
void Awake() { socket = GetComponent<NetSocket>(); database = GetComponent<StreamDatabaseServer>(); loginServer = GetComponent<LoginServer>(); viewManager = GetComponent<NetViewManager>(); loginServer.OnLoginSuccess += LoggedIn; socket.RegisterRpcListener(this); socket.Events.OnClientDisconnected += ClientDisconnected; }
public void AppendReceivedMessage(NetSocket socket, byte[] buffer, int size) { outTime = 0; isConnected = true; NetHeader nh = NetBase.ByteArrayToNetHeader(buffer); // we are waiting for received confirmation from the other side if ((nh.option & NetBase.NET_OPTN_CONFIRMED) > 0) { if (nh.number == confirmNumber && nh.checksum == confirmChecksum) { Debug.Log("Info: Message number has been confirmed from other side!"); confirmNumber = 0; // confirmed retryTime = 0; // remove the message from the sending list m_sendingPacks.RemoveAt(0); } else { // do nothing !! } } else { // replay to sender that safe message has been received if ((nh.option & NetBase.NET_OPTN_SAFESEND) > 0) { NetPacket tmp = new NetPacket(); tmp.header = nh; tmp.header.option = NetBase.NET_OPTN_CONFIRMED; socket.Send(tmp, dest); } // create message container and append it to the list if (nh.number != recvNumber) { recvNumber = nh.number; NetPacket np = new NetPacket(); np.header = nh; np.data = new byte[size - NetBase.NET_HEADER_SIZE]; Buffer.BlockCopy(buffer, NetBase.NET_HEADER_SIZE, np.data, 0, np.data.Length); // add it to the received list m_receivedPacks.Add(np); //sx_print( L"message received header [NO: %d OP: %d CH: %d]\n", np.header.number, np.header.option, np.header.checksum ); } } }
private void OnNetStatusChanged(NetSocket s) { if (s.Connected) { Debug.LogFormat("Socket Status : {0}", "Connected To Sever"); } else { Debug.LogFormat("Socket Status : {0}", "Disconnected To Sever"); } }
private static void SendCB(IAsyncResult ar) { NetSocket obj = (NetSocket)ar.AsyncState; if (obj.sendq.Count == 0) { return; } byte[] a = (byte[])obj.sendq.Dequeue(); obj.doSend(a); return; }
/// <summary> /// Initialize object, open socket. /// </summary> /// <param name="endPoint">NTP Server endpoint</param> /// <param name="onRequestComplete">callback (called from other thread!)</param> private NtpRequest(IPEndPoint endPoint, Action <NtpPacket> onRequestComplete) { _ntpEndPoint = endPoint; _onRequestComplete = onRequestComplete; // Create and start socket _socket = new NetSocket(this); _socket.Bind(IPAddress.Any, IPAddress.IPv6Any, 0, false, endPoint.AddressFamily == AddressFamily.InterNetworkV6 ? IPv6Mode.SeparateSocket : IPv6Mode.Disabled); }
/// <summary> /// Just call receive from the main socket /// </summary> /// <returns>Returns the amount of bytes received. 0 if nothing is received or an exception occurs. You can access the buffer using ReceiveBuffer</returns> public int SimpleReceive() { try { var receivedBytesAmount = NetSocket.Receive(ReceiveBuffer); return(receivedBytesAmount); } catch (SocketException ex) { return(0); } }
public bool is_online; //是否在线 public void FromBin(NetSocket.ByteArray bin) { bin.Get_(out char_idx); char_name = bin.GetStringData((int)twp.app.unit.EUnitLimit.LIMIT_NAME_STR_LENGTH+1); byte v; bin.Get_(out v); relation_type = (RelationType)v; bin.Get_(out battle_integral); sbyte isonline; bin.Get_(out isonline); is_online = (isonline == 0)? false : true; }
public twp.app.resource.Engineer[] engineer = new twp.app.resource.Engineer[(int)twp.app.city.EAreaDefLimit.LIMIT_MAX_AREA_COUNT]; //工程师 public void FromBin(NetSocket.ByteArray bin) { for (UInt16 i = 0; i < (UInt16)twp.app.city.EAreaDefLimit.LIMIT_MAX_AREA_COUNT; ++i) { resource [i] = new twp.app.resource.Resource (); resource [i].FromBin (bin); } for (UInt16 i = 0; i < (UInt16)twp.app.city.EAreaDefLimit.LIMIT_MAX_AREA_COUNT; ++i) { engineer [i] = new twp.app.resource.Engineer (); engineer [i].FromBin (bin); } }
private async Task HandleTCPRT(NetSocket netSocket) { Guid guid = Guid.NewGuid(); tempUsersDick.Add(guid.ToString(), netSocket); // TODO Complete TCP Connection WritePacket wr = new WritePacket(NetManager.RT_PACKET_OPCODE0); wr.AddString(guid.ToString()); netSocket.Send(wr); await Task.FromResult(true); }
public new void FromBin(NetSocket.ByteArray bin) { base.FromBin(bin); bin.Get_(out char_count); bin.Get_(out last_sel_idx); for(int i = 0; i <char_count; i++) { twp.app.unit.CharacterBase ch = new twp.app.unit.CharacterBase(); ch.FromBin(bin); char_data.Add(ch); } }
public bool SendCardStatus(int card_num, bool is_activate, DateTime expire_date) { byte[] dataSend = new byte[16]; //Session Id byte[] _sessionIdBytes = BitConverter.GetBytes(this.SessionId); dataSend[0] = _sessionIdBytes[1]; dataSend[1] = _sessionIdBytes[0]; //CAS version dataSend[2] = 2; //Command type dataSend[3] = 11; //Activate/deactivate the cards //Data length dataSend[4] = 0; dataSend[5] = 10; //Card number byte[] cardNumBytes = BitConverter.GetBytes(card_num); dataSend[6] = cardNumBytes[3]; dataSend[7] = cardNumBytes[2]; dataSend[8] = cardNumBytes[1]; dataSend[9] = cardNumBytes[0]; //Send or not dataSend[10] = Convert.ToByte(true); //Card status dataSend[11] = Convert.ToByte(is_activate); //Expired time Int32 unixTimestamp = (Int32)(expire_date.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; byte[] expiredByBytes = BitConverter.GetBytes(unixTimestamp); dataSend[12] = expiredByBytes[3]; dataSend[13] = expiredByBytes[2]; dataSend[14] = expiredByBytes[1]; dataSend[15] = expiredByBytes[0]; try { ReceivedDataLength = 11; NetSocket.Send(dataSend, 0, dataSend.Length, SocketFlags.None); return(!this.ReceiveResponse().Trim().Split(' ').Skip(6).Any(c => c != "00")); } catch (Exception ex) { ErrorEx = ex.Message; return(false); } }
void Awake() { socket = GetComponent <NetSocket>(); database = GetComponent <StreamDatabaseServer>(); loginServer = GetComponent <LoginServer>(); viewManager = GetComponent <NetViewManager>(); loginServer.OnLoginSuccess += LoggedIn; socket.RegisterRpcListener(this); socket.Events.OnClientDisconnected += ClientDisconnected; }
/// <summary> /// Sends the specified <see cref="NetMessage"/> to the service. /// </summary> public void SendMessage(int serviceNodeType, NetMessage message) { NetSocket socket = this._serviceNodeSockets[serviceNodeType]; if (socket != null) { NetMessageManager.SendMessage(socket, this.SessionId, message); } else { Logging.Warning("NetSession::sendMessage server is not set, nodeType: " + serviceNodeType); } }
public bool SendPinResetRequest(int card_num, DateTime expired_time) { byte[] _dataSend = new byte[6 + 8]; //Session Id byte[] _sessionIdBytes = BitConverter.GetBytes(this.SessionId); _dataSend[0] = _sessionIdBytes[1]; _dataSend[1] = _sessionIdBytes[0]; //CAS version _dataSend[2] = 2; //Command type _dataSend[3] = 3; //Reset Pin code //Data length Int16 _dataLength = 8;//Convert.ToInt16(ContentLength + 13); byte[] _dataLengthBytes = BitConverter.GetBytes(_dataLength); _dataSend[4] = _dataLengthBytes[1]; _dataSend[5] = _dataLengthBytes[0]; //Card number byte[] _cardNumBytes = BitConverter.GetBytes(card_num); _dataSend[6] = _cardNumBytes[3]; _dataSend[7] = _cardNumBytes[2]; _dataSend[8] = _cardNumBytes[1]; _dataSend[9] = _cardNumBytes[0]; //Expired time Int32 _totalSeconds = (Int32)(expired_time.AddHours(1).Subtract(new DateTime(1970, 1, 1))).TotalSeconds; int result = (Int32)DateTime.Now.Subtract(DateTime.MinValue).TotalSeconds; //Int32 _totalSeconds = (Int32)(date.AddHours(1).Second); byte[] _expiredByBytes = BitConverter.GetBytes(_totalSeconds); _dataSend[10] = _expiredByBytes[3]; _dataSend[11] = _expiredByBytes[2]; _dataSend[12] = _expiredByBytes[1]; _dataSend[13] = _expiredByBytes[0]; try { NetSocket.Send(_dataSend, 0, _dataSend.Length, SocketFlags.None); return(!this.ReceiveResponse().Trim().Split(' ').Skip(6).Any(c => c != "00")); } catch (Exception ex) { ErrorEx = ex.Message; return(false); } }
protected void DoSend() { if (!IsConnected) { return; } lock (isSendingLocker) { if (isSending) { return; } } byte[] sendBytes = null; lock (cachedWillSendMessageLocker) { if (cachedWillSendMessages.Count > 0) { var willSendMessage = cachedWillSendMessages[0]; cachedWillSendMessages.RemoveAt(0); sendBytes = Serialize(willSendMessage.ID, willSendMessage.CompressType, willSendMessage.CryptoType, willSendMessage.DataBytes); willSendMessagePool.Release(willSendMessage); } else { return; } } lock (isSendingLocker) { isSending = true; } if (sendAsyncEvent == null) { sendAsyncEvent = new SocketAsyncEventArgs(); sendAsyncEvent.Completed += OnHandleSocketEvent; } sendAsyncEvent.SetBuffer(sendBytes, 0, sendBytes.Length); if (NetSocket.SendAsync(sendAsyncEvent)) { return; } OnSessionError(NetworkSessionError.DoSendFailedError); }
private async Task <bool> AddClient(string roomId, string clientId, NetSocket netSocket) { if (RoomsDic.TryGetValue(roomId, out Room room)) { return(await room.Add(clientId, netSocket)); } else { room = new Room(roomId); await room.Add(clientId, netSocket); return(await AddRoom(roomId, room)); } }
public byte worker_house; //矮人工匠屋数量 #endif public void FromBin(NetSocket.ByteArray bin) { #if false bin.Get_ (out silver); // 银 bin.Get_ (out copper); // 铜 bin.Get_ (out copper_max); // 铜上限 bin.Get_ (out food); // 粮食 bin.Get_ (out food_max); // 粮食上限 bin.Get_ (out population); // 人口 bin.Get_ (out population_max); // 最大人口 #else bin.Get_ (out worker_house); #endif }
private void Start() { socket = GetComponent<NetSocket>(); viewManager = GetComponent<NetViewManager>(); zoneClient = GetComponent<NetZoneClient>(); ExampleItems.PopulateItemDatabase(); zoneClient.OnZoneSetupSuccess += ZoneSetupSuccessful; socket.Events.OnDisconnectedFromServer += DisconnectedFromServer; socket.StartSocket(); socket.RegisterRpcListener(this); }
private void Start() { socket = GetComponent<NetSocket>(); viewManager = GetComponent<NetViewManager>(); zoneClient = GetComponent<NetZoneClient>(); zoneClient.OnZoneSetupSuccess += ZoneSetupSuccessful; socket.Events.OnDisconnectedFromServer += DisconnectedFromServer; socket.Events.OnConnectedToServer += ConnectedToServer; socket.StartSocket(); socket.RegisterRpcListener(this); socket.Connect(ServerAddress); }
public new void FromBin(NetSocket.ByteArray bin) { base.FromBin (bin); int login_result_; bin.Get_ (out login_result_); login_result = (twp.protocol.login.LoginResult)login_result_; int login_type_; bin.Get_ (out login_type_); login_type = (twp.protocol.login.LoginType)login_type_; bin.Get_ (out data_len); for(int i = 0; i < data_len; ++i) { bin.Get_ (out data[i]); } }
private void Start() { socket = GetComponent<NetSocket>(); viewManager = GetComponent<NetViewManager>(); zoneManager = GetComponent<NetZoneManager>(); zoneServer = GetComponent<NetZoneServer>(); zoneServer.OnAssignment += AssignedToZone; socket.ProtocolAuthority = true; socket.AcceptConnections = true; socket.MaxConnections = 512; socket.Events.OnClientDisconnected += ClientDisconnected; socket.Events.OnPeerApproval += PeerApproval; socket.Events.OnSocketStart += SocketStart; socket.Events.OnFailedToConnect += FailedToConnect; socket.StartSocket(ServerAddress + ":" + ServerPortRoot); socket.RegisterRpcListener(this); }
private void Awake() { socket = GetComponent<NetSocket>(); uiManager = GetComponent<UiManager>(); if (socket == null || uiManager == null) { Debug.LogError("Missing required component."); return; } socket.RegisterRpcListener(this); socket.Events.OnConnectedToServer += ConnectedToServer; socket.Events.OnSocketStart += ConnectToLoginServer; socket.Events.OnFailedToConnect += ConnectFailed; socket.Events.OnDisconnectedFromServer += DisconnectedFromServer; Button.ListenForClick(LoginButtonName, LoginClicked); Button.ListenForClick(RegisterButtonName, RegisterClicked); TextFieldInput.ListenForSubmit(UsernameInputName, Submit); TextFieldInput.ListenForSubmit(PasswordInputName, Submit); }
private void Start() { socket = GetComponent<NetSocket>(); zoneManager = GetComponent<NetZoneManager>(); zoneServer = GetComponent<NetZoneServer>(); aiManager = GetComponent<AiManager>(); ExampleItems.PopulateItemDatabase(); zoneServer.OnAssignment += AssignedToZone; socket.ProtocolAuthority = true; socket.AcceptConnections = true; socket.MaxConnections = 512; socket.Events.OnPeerApproval += PeerApproval; socket.Events.OnSocketStart += SocketStart; socket.Events.OnFailedToConnect += FailedToConnect; socket.StartSocket(ServerAddress + ":" + ServerPortRoot); socket.RegisterRpcListener(this); }
public void FromBin(NetSocket.ByteArray bin) { bin.Get_(out header); }
public byte engineer_idle; // 闲置 public void FromBin(NetSocket.ByteArray bin) { bin.Get_ (out engineer_use); // 使用中 bin.Get_ (out engineer_idle); // 闲置 }
// TODO: Released streams break everything. Copy streams. void Awake() { socket = GetComponent<NetSocket>(); socket.RegisterRpcListener(this); }
void OnGUI() { if (mode == netMode.client) { if (GUI.Button(new Rect(10, 10, 50, 50), "Client")) { } } else if (mode == netMode.server) { if (GUI.Button(new Rect(10, 10, 50, 50), "Server")) { } if (GUI.Button(new Rect(10, 70, 50, 50), "Peers")) { zoneManager.ListPeers(); } if (GUI.Button(new Rect(10, 140, 50, 50), "UPeers")) { zoneManager.ListUPeers(); } } else { if (GUI.Button(new Rect(10, 10, 50, 50), "Server")) { mode = netMode.server; // netManager = (GameObject)GameObject.Instantiate(Resources.Load("ServerGameManager")); gameObject.AddComponent<NetSocket>(); socket = GetComponent<NetSocket>(); gameObject.AddComponent<NetViewManager>(); viewManager = GetComponent<NetViewManager>(); gameObject.AddComponent<NetZoneManager>(); zoneManager = GetComponent<NetZoneManager>(); gameObject.AddComponent<NetZoneServer>(); zoneServer = GetComponent<NetZoneServer>(); zoneServer.OnAssignment += AssignedToZone; gameObject.AddComponent<NetScopeManager>(); socket.ProtocolAuthority = true; socket.AcceptConnections = true; socket.MaxConnections = 512; socket.Events.OnClientDisconnected += ClientDisconnected; socket.Events.OnPeerApproval += PeerApproval; socket.Events.OnSocketStart += SocketStart; socket.Events.OnFailedToConnect += FailedToConnect; socket.StartSocket(ServerAddress + ":" + ServerPortRoot); socket.RegisterRpcListener(this); serverCamera.enabled = true; } if (GUI.Button(new Rect(10, 70, 50, 30), "Client")) { mode = netMode.client; netManager = (GameObject)GameObject.Instantiate(Resources.Load("ClientGameManager")); } } }
/// <summary> Releases a stream back to the pool for reuse. This should be called once a stream is no longer needed. </summary> public void Release() { if (Pool.Count > MaxSize) return; Reset(); Connection = null; Socket = null; WriteLength = false; if (!Pool.Contains(this)) Pool.Enqueue(this); }
public void FromBin(NetSocket.ByteArray bin) { bin.Get_ (out x); bin.Get_ (out y); }
internal RpcDispatcher(NetSocket socket) { Socket = socket; }