public override void ZeusDisconnected(UdpKit.UdpEndPoint endpoint) { base.ZeusDisconnected(endpoint); App.shared.Log("ZeusDisconnected", this); if (networkDelegate != null) { networkDelegate.ZeusDisconnected(); } }
//Game was full public override void ConnectRefused(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token) { base.ConnectRefused(endpoint, token); App.shared.Log("ConnectRefused", this); if (networkDelegate != null) { networkDelegate.ConnectRefused(endpoint, token); } }
public override int SendTo(byte[] buffer, int bytesToSend, UdpKit.UdpEndPoint endpoint) { var bytesSent = NativePInvoke.SendTo(socket, buffer, bytesToSend, endpoint.AsNative); if (bytesSent >= 0) { return bytesSent; } UdpLog.Error(Error); return -1; }
public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token) { BoltLog.Warn("ConnectRequest"); if (token != null) { BoltLog.Info("Token Received"); } BoltNetwork.Accept(endpoint); }
public override void ConnectRequest(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token) { BoltConsole.Write("ConnectRequest", Color.red); if (token != null) { BoltConsole.Write("Token Received", Color.red); } BoltNetwork.Accept(endpoint); }
public override void ConnectRefused(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token) { title = "Connection Refused"; if (token != null && token is DisconnectReason) { DisconnectReason reason = (DisconnectReason)token; messageBody = reason.Reason + (reason.Message == "" ? "" : ": " + reason.Message); } else { messageBody = "Unknown Error"; } messageDisplayed = true; }
public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpKit.UdpEndPoint remoteEndpoint) { var host = ""; var port = ""; var bytes = socket.RecvFrom(buffer, bufferSize, ref host, ref port); if (bytes > 0 && host != null && port != null) { remoteEndpoint = UdpKit.UdpEndPoint.Parse(host + ":" + port); return(bytes); } return(0); }
public override int RecvFrom(byte[] buffer, int bufferSize, ref UdpKit.UdpEndPoint endpoint) { var sender = default(UdpEndPoint.Native); var bytesReceived = NativePInvoke.RecvFrom(socket, buffer, bufferSize, out sender); if (bytesReceived > 0) { endpoint = sender.AsManaged; } if (bytesReceived < 0) { UdpLog.Error(Error); bytesReceived = -1; } return bytesReceived; }
// Callback triggered when this instance receives an incoming client connection public override void ConnectRequest(UdpKit.UdpEndPoint endpoint) { print("S ConnectRequest 1"); Vector3 connectedPlayerStarting = PlayerObjectRegistry.PlayerConnect(); print("Connected starting: " + connectedPlayerStarting); if (PlayerObjectRegistry.connectedPlayerCount > 4) { BoltNetwork.Refuse(endpoint, null); } else { CameraSpawnPoint csp = new CameraSpawnPoint(connectedPlayerStarting); //print("Connect request, setting spawn point: " + csp.position); BoltNetwork.Accept(endpoint, null, csp, null); } }
void SendRefusedCommand(UdpEndPoint endpoint) { UdpBitStream stream = new UdpBitStream(GetWriteBuffer(), Config.DefaultMtu, UdpHeader.GetSize(this)); stream.WriteByte((byte)UdpCommandType.Refused, 8); UdpHeader header = new UdpHeader(); header.IsObject = false; header.AckHistory = 0; header.AckSequence = 1; header.ObjSequence = 1; header.Now = 0; header.Pack(new UdpBitStream(stream.Data, Config.DefaultMtu, 0), this); if (Send(endpoint, stream.Data, UdpMath.BytesRequired(stream.Ptr)) == false) { // do something here? } }
void SendRefusedCommand(UdpEndPoint endpoint) { UdpStream stream = GetWriteStream(Config.PacketSize << 3, HeaderBitSize); stream.WriteByte((byte)UdpCommandType.Refused, 8); UdpHeader header = new UdpHeader(); header.IsObject = false; header.AckHistory = 0; header.AckSequence = 1; header.ObjSequence = 1; header.Now = 0; header.Pack(stream, this); if (Send(endpoint, stream.Data, UdpMath.BytesRequired(stream.Ptr)) == false) { // do something here? } }
public override void Bind(UdpKit.UdpEndPoint ep) { CheckResult(NativePInvoke.Bind(socket, ep.AsNative)); }
/// <summary> /// Refuse a connection request from a remote endpoint /// </summary> /// <param name="endpoint">The endpoint to refuse</param> public void Refuse(UdpEndPoint endpoint) { Raise(UdpEvent.INTERNAL_REFUSE, endpoint); }
public override void ConnectFailed(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token) { base.ConnectFailed(endpoint, token); sendResult(false); }
/// <summary> /// Start this socket /// </summary> /// <param name="endpoint">The endpoint to bind to</param> public void Start(UdpEndPoint endpoint) { Raise(UdpEvent.INTERNAL_START, endpoint); }
partial void DelayPacket(UdpEndPoint ep, byte[] data, int length);
static IPEndPoint ConvertEndPoint(UdpKit.UdpEndPoint endpoint) { return(new IPEndPoint(new IPAddress(new byte[] { endpoint.Address.Byte3, endpoint.Address.Byte2, endpoint.Address.Byte1, endpoint.Address.Byte0 }), endpoint.Port)); }
public override int SendTo(byte[] buffer, int bytesToSend, UdpKit.UdpEndPoint endpoint) { return(socket.SendTo(buffer, bytesToSend, endpoint.Address.ToString(), endpoint.Port.ToString())); }
public override void Bind(UdpKit.UdpEndPoint ep) { socket.Bind(ep.Port.ToString()); }
/// <summary> /// Cancel ongoing attempt to connect to endpoint /// </summary> /// <param name="endpoint">The endpoint to cancel connect attempt to</param> public void CancelConnect(UdpEndPoint endpoint) { Raise(UdpEvent.INTERNAL_CONNECT_CANCEL, endpoint); }
public override bool RecvFrom(byte[] buffer, int bufferSize, ref int bytesReceived, ref UdpEndPoint remoteEndpoint) { UdpEndPoint nativeEndpoint = default(UdpEndPoint); fixed(byte *p = buffer) { bytesReceived = UdpNativeInvoke.udpRecvFrom(ptr, new IntPtr(p), bufferSize, &nativeEndpoint); } if (bytesReceived > 0) { remoteEndpoint = nativeEndpoint; return(true); } return(false); }
void AcceptConnection(UdpEndPoint ep, object replyObj) { UdpConnection cn = CreateConnection(ep, UdpConnectionMode.Server, replyObj); cn.ChangeState(UdpConnectionState.Connected); }
public override bool RecvFrom(byte[] buffer, int bufferSize, ref int bytesReceived, ref UdpEndPoint remoteEndpoint) { try { bytesReceived = socket.ReceiveFrom(buffer, 0, bufferSize, SocketFlags.None, ref recvEndPoint); if (bytesReceived > 0) { remoteEndpoint = ConvertEndPoint((IPEndPoint)recvEndPoint); return(true); } else { return(false); } } catch (SocketException exn) { socketError = exn.SocketErrorCode; return(false); } }
public override bool Bind(UdpEndPoint endpoint) { return(UdpNativeInvoke.udpBind(ptr, endpoint) == UdpNativeInvoke.UDPKIT_SOCKET_OK); }
/// <summary> /// Connect to remote endpoint /// </summary> /// <param name="endpoint">The endpoint to connect to</param> public void Connect(UdpEndPoint endpoint) { Raise(UdpEvent.INTERNAL_CONNECT, endpoint); }
public override void ZeusConnected(UdpKit.UdpEndPoint endpoint) { Debug.Log("Connected to Zeus server " + endpoint); zeusServer = endpoint; zeusConnected = true; }
/// <summary> /// Accept a connection request from a remote endpoint /// </summary> /// <param name="endpoint">The endpoint to accept</param> public void Accept(UdpEndPoint endpoint) { Raise(UdpEvent.INTERNAL_ACCEPT, endpoint); }
public override void ZeusConnectFailed(UdpKit.UdpEndPoint endpoint) { Debug.LogWarning("Failed to connect to Zeus server " + endpoint); zeusConnected = false; }
void AcceptConnection(UdpEndPoint ep) { UdpConnection cn = CreateConnection(ep, UdpConnectionMode.Server); cn.ChangeState(UdpConnectionState.Connected); }
public override void ZeusDisconnected(UdpKit.UdpEndPoint endpoint) { Debug.LogWarning("Disconnected from Zeus server " + endpoint); zeusConnected = false; }