Exemplo n.º 1
0
 public override void ZeusDisconnected(UdpKit.UdpEndPoint endpoint)
 {
     base.ZeusDisconnected(endpoint);
     App.shared.Log("ZeusDisconnected", this);
     if (networkDelegate != null)
     {
         networkDelegate.ZeusDisconnected();
     }
 }
Exemplo n.º 2
0
 //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);
     }
 }
Exemplo n.º 3
0
  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);
        }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
    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);
    }
Exemplo n.º 8
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;
  }
Exemplo n.º 9
0
    // 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);
        }
    }
Exemplo n.º 10
0
        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?
            }
        }
Exemplo n.º 11
0
        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?
            }
        }
Exemplo n.º 12
0
 public override void Bind(UdpKit.UdpEndPoint ep) {
   CheckResult(NativePInvoke.Bind(socket, ep.AsNative));
 }
Exemplo n.º 13
0
 /// <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);
    }
Exemplo n.º 15
0
 /// <summary>
 /// Start this socket
 /// </summary>
 /// <param name="endpoint">The endpoint to bind to</param>
 public void Start(UdpEndPoint endpoint)
 {
     Raise(UdpEvent.INTERNAL_START, endpoint);
 }
Exemplo n.º 16
0
 partial void DelayPacket(UdpEndPoint ep, byte[] data, int length);
Exemplo n.º 17
0
 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));
 }
Exemplo n.º 18
0
 public override int SendTo(byte[] buffer, int bytesToSend, UdpKit.UdpEndPoint endpoint)
 {
     return(socket.SendTo(buffer, bytesToSend, endpoint.Address.ToString(), endpoint.Port.ToString()));
 }
Exemplo n.º 19
0
 public override void Bind(UdpKit.UdpEndPoint ep)
 {
     socket.Bind(ep.Port.ToString());
 }
Exemplo n.º 20
0
 /// <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);
 }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        void AcceptConnection(UdpEndPoint ep, object replyObj)
        {
            UdpConnection cn = CreateConnection(ep, UdpConnectionMode.Server, replyObj);

            cn.ChangeState(UdpConnectionState.Connected);
        }
Exemplo n.º 23
0
        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);
            }
        }
Exemplo n.º 24
0
 public override bool Bind(UdpEndPoint endpoint)
 {
     return(UdpNativeInvoke.udpBind(ptr, endpoint) == UdpNativeInvoke.UDPKIT_SOCKET_OK);
 }
Exemplo n.º 25
0
 /// <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);
 }
Exemplo n.º 26
0
 public override void ZeusConnected(UdpKit.UdpEndPoint endpoint)
 {
     Debug.Log("Connected to Zeus server " + endpoint);
     zeusServer    = endpoint;
     zeusConnected = true;
 }
Exemplo n.º 27
0
 /// <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);
 }
Exemplo n.º 28
0
 public override void ZeusConnectFailed(UdpKit.UdpEndPoint endpoint)
 {
     Debug.LogWarning("Failed to connect to Zeus server " + endpoint);
     zeusConnected = false;
 }
Exemplo n.º 29
0
        void AcceptConnection(UdpEndPoint ep)
        {
            UdpConnection cn = CreateConnection(ep, UdpConnectionMode.Server);

            cn.ChangeState(UdpConnectionState.Connected);
        }
Exemplo n.º 30
0
 public override void ZeusDisconnected(UdpKit.UdpEndPoint endpoint)
 {
     Debug.LogWarning("Disconnected from Zeus server " + endpoint);
     zeusConnected = false;
 }