Пример #1
0
 private static string colorFeatState(UdpKit.NatFeatureStates val)
 {
     switch (val) {
         case UdpKit.NatFeatureStates.Yes: return "<color=green>Yes</color>";
         case UdpKit.NatFeatureStates.No: return "<color=red>No</color>";
         case UdpKit.NatFeatureStates.Unknown: return "<color=blue>Unknown</color>";
         default: return "";
     }
 }
Пример #2
0
 //callback when the session list is updated, redraws the list
 public override void SessionListUpdated(UdpKit.Map<System.Guid, UdpKit.UdpSession> sessionList)
 {
     Debug.Log("Zeus session list updated");
     destroyAllEntries();
     foreach (var entry in sessionList) {
         createEntryForSession(entry.Value);
     }
     refreshButton.interactable = true;
 }
Пример #3
0
    public Wp8Interface(UdpKit.UdpIPv4Address address)
    {
        unicast = new UdpKit.UdpIPv4Address[1] { address };

        address.Byte0 = 1;
        gateway = new UdpKit.UdpIPv4Address[1] { address };

        address.Byte0 = 255;
        multicast = new UdpKit.UdpIPv4Address[2] { UdpKit.UdpIPv4Address.Broadcast, address };
    }
 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;
 }
Пример #5
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;
  }
 public void Read(UdpKit.UdpPacket packet)
 {
     ServerName = packet.ReadString();
     MOTD = packet.ReadString();
     GameMode = packet.ReadString();
     MapName = packet.ReadString();
     PlayerCount = packet.ReadByte();
     MaxPlayerCount = packet.ReadByte();
     byte flags = packet.ReadByte();
     PasswordRequired = (flags & PASSWORD_REQUIRED_MASK) != 0;
     IsDedicatedServer = (flags & DEDICATED_MASK) != 0;
     HideInServerList = (flags & HIDE_MASK) != 0;
 }
 public void Write(UdpKit.UdpPacket packet)
 {
     packet.WriteString(ServerName);
     packet.WriteString(MOTD);
     packet.WriteString(GameMode);
     packet.WriteString(MapName);
     packet.WriteByte(PlayerCount);
     packet.WriteByte(MaxPlayerCount);
     byte flags = 0;
     if (PasswordRequired) flags |= PASSWORD_REQUIRED_MASK;
     if (IsDedicatedServer) flags |= DEDICATED_MASK;
     if (HideInServerList) flags |= HIDE_MASK;
     packet.WriteByte(flags);
 }
Пример #8
0
 public override void ZeusNatProbeResult(UdpKit.NatFeatures features)
 {
     natProbeValid = true;
     natFeatures = features;
     Debug.Log("Nat Probe Result:\nAllowsUnsolicitedTraffic: " + features.AllowsUnsolicitedTraffic +
         "\nLANEndpoint: " + features.LanEndPoint +
         "\nSupportsEndPointPreservation: " + features.SupportsEndPointPreservation +
         "\nSupportsHairpinTranslation: " + features.SupportsHairpinTranslation +
         "\nWanEndPoint: " + features.WanEndPoint);
     natInfoText.text = "<b>NAT Status</b>" +
         "\nAllows unsolicited traffic: " + colorFeatState(features.AllowsUnsolicitedTraffic) +
         "\nLAN endpoint: " + features.LanEndPoint +
         "\nSupports endpoint preservation: " + colorFeatState(features.SupportsEndPointPreservation) +
         "\nSupports hairpin translation: " + colorFeatState(features.SupportsHairpinTranslation) +
         "\nWAN endpoint: " + features.WanEndPoint;
 }
    public override void ConnectFailed(UdpKit.UdpEndPoint endpoint, Bolt.IProtocolToken token)
    {
        base.ConnectFailed(endpoint, token);

        sendResult(false);
    }
Пример #10
0
    return bytesReceived;
  }
Пример #11
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;
  }

  bool CheckResult(int result) {
    if (result == NativePInvoke.UDPKIT_SOCKET_OK) {
      return true;
    }
Пример #12
0
 public override void ZeusConnectFailed(UdpKit.UdpEndPoint endpoint)
 {
     Debug.LogWarning("Failed to connect to Zeus server " + endpoint);
     zeusConnected = false;
 }
Пример #13
0
    if (result == NativePInvoke.UDPKIT_SOCKET_NODATA) {
      return false;
    }

    throw new Exception(string.Format("Unknown return code: {0}", result));
  }
}
#endif
Пример #14
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);
 }
Пример #15
0
 public void Pop(UdpKit.UdpSession session)
 {
     this.session = session;
     this.password = "";
     gameObject.SetActive(true);
 }
Пример #16
0
 public override void ZeusDisconnected(UdpKit.UdpEndPoint endpoint)
 {
     Debug.LogWarning("Disconnected from Zeus server "+endpoint);
     zeusConnected = false;
 }
Пример #17
0
 public override int SendTo(byte[] buffer, int bytesToSend, UdpKit.UdpEndPoint endpoint) {
   return socket.SendTo(buffer, bytesToSend, endpoint.Address.ToString(), endpoint.Port.ToString());
 }
Пример #18
0
 public override void ZeusConnected(UdpKit.UdpEndPoint endpoint)
 {
     Debug.Log("Connected to Zeus server " + endpoint);
     zeusServer = endpoint;
     zeusConnected = true;
 }
 public void Read(UdpKit.UdpPacket packet)
 {
     Reason = packet.ReadString();
     Message = packet.ReadString();
 }
Пример #20
0
 //creates an item in the list
 private void createEntryForSession(UdpKit.UdpSession session)
 {
     GameObject obj = Instantiate<GameObject>(listEntryPrefab);
     listEntries.Add(obj);
     obj.transform.SetParent(scrollPanel, false);
     EntryPanel entry = obj.GetComponent<EntryPanel>();
     entry.session = session;
     entry.passwordPanel = passwordPanel;
 }
 public void Read(UdpKit.UdpPacket packet)
 {
     PlayerName = packet.ReadString();
     Password = packet.ReadString();
 }
 public void Write(UdpKit.UdpPacket packet)
 {
     packet.WriteString(PlayerName);
     packet.WriteString(Password);
 }
 public void Write(UdpKit.UdpPacket packet)
 {
     packet.WriteString(Reason);
     packet.WriteString(Message);
 }
Пример #24
0
 public override void Bind(UdpKit.UdpEndPoint ep) {
   socket.Bind(ep.Port.ToString());
 }