| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444 |
- // WARNING - AUTOGENERATED - DO NOT EDIT
- //
- // Generated using `sharpie urho`
- //
- // Network.cs
- //
- // Copyright 2015 Xamarin Inc. All rights reserved.
- using System;
- using System.Runtime.InteropServices;
- using System.Collections.Generic;
- using Urho.Urho2D;
- using Urho.Gui;
- using Urho.Resources;
- using Urho.IO;
- using Urho.Navigation;
- using Urho.Network;
- namespace Urho.Network
- {
- /// <summary>
- /// %Network subsystem. Manages client-server communications using the UDP protocol.
- /// </summary>
- public unsafe partial class Network : UrhoObject
- {
- unsafe partial void OnNetworkCreated ();
- [Preserve]
- public Network (IntPtr handle) : base (handle)
- {
- OnNetworkCreated ();
- }
- [Preserve]
- protected Network (UrhoObjectFlag emptyFlag) : base (emptyFlag)
- {
- OnNetworkCreated ();
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern int Network_GetType (IntPtr handle);
- private StringHash UrhoGetType ()
- {
- Runtime.ValidateRefCounted (this);
- return new StringHash (Network_GetType (handle));
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern IntPtr Network_GetTypeName (IntPtr handle);
- private string GetTypeName ()
- {
- Runtime.ValidateRefCounted (this);
- return Marshal.PtrToStringAnsi (Network_GetTypeName (handle));
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern int Network_GetTypeStatic ();
- private static StringHash GetTypeStatic ()
- {
- Runtime.Validate (typeof(Network));
- return new StringHash (Network_GetTypeStatic ());
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern IntPtr Network_GetTypeNameStatic ();
- private static string GetTypeNameStatic ()
- {
- Runtime.Validate (typeof(Network));
- return Marshal.PtrToStringAnsi (Network_GetTypeNameStatic ());
- }
- [Preserve]
- public Network () : this (Application.CurrentContext)
- {
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern IntPtr Network_Network (IntPtr context);
- [Preserve]
- public Network (Context context) : base (UrhoObjectFlag.Empty)
- {
- Runtime.Validate (typeof(Network));
- handle = Network_Network ((object)context == null ? IntPtr.Zero : context.Handle);
- Runtime.RegisterObject (this);
- OnNetworkCreated ();
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_Disconnect (IntPtr handle, int waitMSec);
- /// <summary>
- /// Disconnect the connection to the server. If wait time is non-zero, will block while waiting for disconnect to finish.
- /// </summary>
- public void Disconnect (int waitMSec = 0)
- {
- Runtime.ValidateRefCounted (this);
- Network_Disconnect (handle, waitMSec);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern bool Network_StartServer (IntPtr handle, ushort port);
- /// <summary>
- /// Start a server on a port using UDP protocol. Return true if successful.
- /// </summary>
- public bool StartServer (ushort port)
- {
- Runtime.ValidateRefCounted (this);
- return Network_StartServer (handle, port);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_StopServer (IntPtr handle);
- /// <summary>
- /// Stop the server.
- /// </summary>
- public void StopServer ()
- {
- Runtime.ValidateRefCounted (this);
- Network_StopServer (handle);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_BroadcastMessage (IntPtr handle, int msgID, bool reliable, bool inOrder, byte* data, uint numBytes, uint contentID);
- /// <summary>
- /// Broadcast a message with content ID to all client connections.
- /// </summary>
- public void BroadcastMessage (int msgID, bool reliable, bool inOrder, byte* data, uint numBytes, uint contentID = 0)
- {
- Runtime.ValidateRefCounted (this);
- Network_BroadcastMessage (handle, msgID, reliable, inOrder, data, numBytes, contentID);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_SetUpdateFps (IntPtr handle, int fps);
- /// <summary>
- /// Set network update FPS.
- /// </summary>
- private void SetUpdateFps (int fps)
- {
- Runtime.ValidateRefCounted (this);
- Network_SetUpdateFps (handle, fps);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_SetSimulatedLatency (IntPtr handle, int ms);
- /// <summary>
- /// Set simulated latency in milliseconds. This adds a fixed delay before sending each packet.
- /// </summary>
- private void SetSimulatedLatency (int ms)
- {
- Runtime.ValidateRefCounted (this);
- Network_SetSimulatedLatency (handle, ms);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_SetSimulatedPacketLoss (IntPtr handle, float probability);
- /// <summary>
- /// Set simulated packet loss probability between 0.0 - 1.0.
- /// </summary>
- private void SetSimulatedPacketLoss (float probability)
- {
- Runtime.ValidateRefCounted (this);
- Network_SetSimulatedPacketLoss (handle, probability);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_RegisterRemoteEvent (IntPtr handle, int eventType);
- /// <summary>
- /// Register a remote event as allowed to be received. There is also a fixed blacklist of events that can not be allowed in any case, such as ConsoleCommand.
- /// </summary>
- public void RegisterRemoteEvent (StringHash eventType)
- {
- Runtime.ValidateRefCounted (this);
- Network_RegisterRemoteEvent (handle, eventType.Code);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_UnregisterRemoteEvent (IntPtr handle, int eventType);
- /// <summary>
- /// Unregister a remote event as allowed to received.
- /// </summary>
- public void UnregisterRemoteEvent (StringHash eventType)
- {
- Runtime.ValidateRefCounted (this);
- Network_UnregisterRemoteEvent (handle, eventType.Code);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_UnregisterAllRemoteEvents (IntPtr handle);
- /// <summary>
- /// Unregister all remote events.
- /// </summary>
- public void UnregisterAllRemoteEvents ()
- {
- Runtime.ValidateRefCounted (this);
- Network_UnregisterAllRemoteEvents (handle);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_SetPackageCacheDir (IntPtr handle, string path);
- /// <summary>
- /// Set the package download cache directory.
- /// </summary>
- private void SetPackageCacheDir (string path)
- {
- Runtime.ValidateRefCounted (this);
- Network_SetPackageCacheDir (handle, path);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_SendPackageToClients (IntPtr handle, IntPtr scene, IntPtr package);
- /// <summary>
- /// Trigger all client connections in the specified scene to download a package file from the server. Can be used to download additional resource packages when clients are already joined in the scene. The package must have been added as a requirement to the scene, or else the eventual download will fail.
- /// </summary>
- public void SendPackageToClients (Scene scene, PackageFile package)
- {
- Runtime.ValidateRefCounted (this);
- Network_SendPackageToClients (handle, (object)scene == null ? IntPtr.Zero : scene.Handle, (object)package == null ? IntPtr.Zero : package.Handle);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern int Network_GetUpdateFps (IntPtr handle);
- /// <summary>
- /// Return network update FPS.
- /// </summary>
- private int GetUpdateFps ()
- {
- Runtime.ValidateRefCounted (this);
- return Network_GetUpdateFps (handle);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern int Network_GetSimulatedLatency (IntPtr handle);
- /// <summary>
- /// Return simulated latency in milliseconds.
- /// </summary>
- private int GetSimulatedLatency ()
- {
- Runtime.ValidateRefCounted (this);
- return Network_GetSimulatedLatency (handle);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern float Network_GetSimulatedPacketLoss (IntPtr handle);
- /// <summary>
- /// Return simulated packet loss probability.
- /// </summary>
- private float GetSimulatedPacketLoss ()
- {
- Runtime.ValidateRefCounted (this);
- return Network_GetSimulatedPacketLoss (handle);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern IntPtr Network_GetServerConnection (IntPtr handle);
- /// <summary>
- /// Return the connection to the server. Null if not connected.
- /// </summary>
- private Connection GetServerConnection ()
- {
- Runtime.ValidateRefCounted (this);
- return Runtime.LookupObject<Connection> (Network_GetServerConnection (handle));
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern bool Network_IsServerRunning (IntPtr handle);
- /// <summary>
- /// Return whether the server is running.
- /// </summary>
- private bool IsServerRunning ()
- {
- Runtime.ValidateRefCounted (this);
- return Network_IsServerRunning (handle);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern bool Network_CheckRemoteEvent (IntPtr handle, int eventType);
- /// <summary>
- /// Return whether a remote event is allowed to be received.
- /// </summary>
- public bool CheckRemoteEvent (StringHash eventType)
- {
- Runtime.ValidateRefCounted (this);
- return Network_CheckRemoteEvent (handle, eventType.Code);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern IntPtr Network_GetPackageCacheDir (IntPtr handle);
- /// <summary>
- /// Return the package download cache directory.
- /// </summary>
- private string GetPackageCacheDir ()
- {
- Runtime.ValidateRefCounted (this);
- return Marshal.PtrToStringAnsi (Network_GetPackageCacheDir (handle));
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_Update (IntPtr handle, float timeStep);
- /// <summary>
- /// Process incoming messages from connections. Called by HandleBeginFrame.
- /// </summary>
- public void Update (float timeStep)
- {
- Runtime.ValidateRefCounted (this);
- Network_Update (handle, timeStep);
- }
- [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
- internal static extern void Network_PostUpdate (IntPtr handle, float timeStep);
- /// <summary>
- /// Send outgoing messages after frame logic. Called by HandleRenderUpdate.
- /// </summary>
- public void PostUpdate (float timeStep)
- {
- Runtime.ValidateRefCounted (this);
- Network_PostUpdate (handle, timeStep);
- }
- public override StringHash Type {
- get {
- return UrhoGetType ();
- }
- }
- public override string TypeName {
- get {
- return GetTypeName ();
- }
- }
- [Preserve]
- public static StringHash TypeStatic {
- get {
- return GetTypeStatic ();
- }
- }
- public static string TypeNameStatic {
- get {
- return GetTypeNameStatic ();
- }
- }
- /// <summary>
- /// Return network update FPS.
- /// Or
- /// Set network update FPS.
- /// </summary>
- public int UpdateFps {
- get {
- return GetUpdateFps ();
- }
- set {
- SetUpdateFps (value);
- }
- }
- /// <summary>
- /// Return simulated latency in milliseconds.
- /// Or
- /// Set simulated latency in milliseconds. This adds a fixed delay before sending each packet.
- /// </summary>
- public int SimulatedLatency {
- get {
- return GetSimulatedLatency ();
- }
- set {
- SetSimulatedLatency (value);
- }
- }
- /// <summary>
- /// Return simulated packet loss probability.
- /// Or
- /// Set simulated packet loss probability between 0.0 - 1.0.
- /// </summary>
- public float SimulatedPacketLoss {
- get {
- return GetSimulatedPacketLoss ();
- }
- set {
- SetSimulatedPacketLoss (value);
- }
- }
- /// <summary>
- /// Return the package download cache directory.
- /// Or
- /// Set the package download cache directory.
- /// </summary>
- public string PackageCacheDir {
- get {
- return GetPackageCacheDir ();
- }
- set {
- SetPackageCacheDir (value);
- }
- }
- /// <summary>
- /// Return the connection to the server. Null if not connected.
- /// </summary>
- public Connection ServerConnection {
- get {
- return GetServerConnection ();
- }
- }
- /// <summary>
- /// Return whether the server is running.
- /// </summary>
- public bool ServerRunning {
- get {
- return IsServerRunning ();
- }
- }
- }
- }
|