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 ""; } }
//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; }
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; }
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); }
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); }
return bytesReceived; }
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; }
public override void ZeusConnectFailed(UdpKit.UdpEndPoint endpoint) { Debug.LogWarning("Failed to connect to Zeus server " + endpoint); zeusConnected = false; }
if (result == NativePInvoke.UDPKIT_SOCKET_NODATA) { return false; } throw new Exception(string.Format("Unknown return code: {0}", result)); } } #endif
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 void Pop(UdpKit.UdpSession session) { this.session = session; this.password = ""; gameObject.SetActive(true); }
public override void ZeusDisconnected(UdpKit.UdpEndPoint endpoint) { Debug.LogWarning("Disconnected from Zeus server "+endpoint); zeusConnected = false; }
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 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(); }
//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); }
public override void Bind(UdpKit.UdpEndPoint ep) { socket.Bind(ep.Port.ToString()); }