Show / Hide Table of Contents

Interface IMyMultiplayer

ModAPI interface giving access to interaction between server and client

Namespace: VRage.Game.ModAPI
Assembly: VRage.Game.dll
Syntax
public interface IMyMultiplayer

Properties

IsServer

Returns if current game instance is server

Declaration
bool IsServer { get; }
Property Value
Type Description
System.Boolean

MultiplayerActive

Gets if game supports several people

Declaration
bool MultiplayerActive { get; }
Property Value
Type Description
System.Boolean

MyId

Gets this game instance id (steamId or other)

Declaration
ulong MyId { get; }
Property Value
Type Description
System.UInt64

MyName

Get current player name

Declaration
string MyName { get; }
Property Value
Type Description
System.String

Players

Gets players currently connected to server

Declaration
IMyPlayerCollection Players { get; }
Property Value
Type Description
IMyPlayerCollection

ServerId

Gets id (steamId or other) of server

Declaration
ulong ServerId { get; }
Property Value
Type Description
System.UInt64

Methods

IsServerPlayer(IMyNetworkClient)

Gets if provided network is a player and also server

Declaration
bool IsServerPlayer(IMyNetworkClient player)
Parameters
Type Name Description
IMyNetworkClient player

Player to test if he is server

Returns
Type Description
System.Boolean

True if provided network is a player and also server

JoinServer(String)

Exiting current server, and joining other server

Declaration
void JoinServer(string address)
Parameters
Type Name Description
System.String address

RegisterMessageHandler(UInt16, Action<Byte[]>)

Declaration
void RegisterMessageHandler(ushort id, Action<byte[]> messageHandler)
Parameters
Type Name Description
System.UInt16 id
System.Action<System.Byte[]> messageHandler

RegisterSecureMessageHandler(UInt16, Action<UInt16, Byte[], UInt64, Boolean>)

Allows you do reliable checks WHO have sent message to you. Action - HandlerId, Package, Player SteamID or 0 for Dedicated server, Sent message comes from server

Declaration
void RegisterSecureMessageHandler(ushort id, Action<ushort, byte[], ulong, bool> messageHandler)
Parameters
Type Name Description
System.UInt16 id

Handler id, may be not unique, but then for each message multiple handlers would be executed

System.Action<System.UInt16, System.Byte[], System.UInt64, System.Boolean> messageHandler

Call function. Arguments: handlerId, messageSentBytes, senderPlayerId, isArrivedFromServer

SendEntitiesCreated(List<MyObjectBuilder_EntityBase>)

Does nothing

Declaration
void SendEntitiesCreated(List<MyObjectBuilder_EntityBase> objectBuilders)
Parameters
Type Name Description
System.Collections.Generic.List<MyObjectBuilder_EntityBase> objectBuilders

Ignored

SendMessageTo(UInt16, Byte[], UInt64, Boolean)

Send message to one recipient.

Declaration
bool SendMessageTo(ushort id, byte[] message, ulong recipient, bool reliable = true)
Parameters
Type Name Description
System.UInt16 id

Some random number from 0-65535, that you use in RegisterSecureMessageHandler(UInt16, Action<UInt16, Byte[], UInt64, Boolean>). Dont use beautiful numbers like 11111, 22222. You may conflict with other mods.

System.Byte[] message

Byte data. Use SerializeToBinary<T>(T)

System.UInt64 recipient

Use SteamUserId. Not IdentityId (long)

System.Boolean reliable

When false, message may not arrive to client, but faster. Unreliable messages are also limited by 1024 bytes.

Returns
Type Description
System.Boolean

True if message was sent

SendMessageToOthers(UInt16, Byte[], Boolean)

Send message to everyone on server (including server)

Declaration
bool SendMessageToOthers(ushort id, byte[] message, bool reliable = true)
Parameters
Type Name Description
System.UInt16 id

Some random number from 0-65535, that you use in RegisterSecureMessageHandler(UInt16, Action<UInt16, Byte[], UInt64, Boolean>). Dont use beautiful numbers like 11111, 22222. You may conflict with other mods.

System.Byte[] message

Byte data. Use SerializeToBinary<T>(T)

System.Boolean reliable

When false, message may not arrive to client, but faster. Unreliable messages are also limited by 1024 bytes.

Returns
Type Description
System.Boolean

True if message was sent

SendMessageToServer(UInt16, Byte[], Boolean)

Send message to server

Declaration
bool SendMessageToServer(ushort id, byte[] message, bool reliable = true)
Parameters
Type Name Description
System.UInt16 id

Some random number from 0-65535, that you use in RegisterSecureMessageHandler(UInt16, Action<UInt16, Byte[], UInt64, Boolean>). Dont use beautiful numbers like 11111, 22222. You may conflict with other mods.

System.Byte[] message

Byte data. Use SerializeToBinary<T>(T)

System.Boolean reliable

When false, message may not arrive to client, but faster. They also may come in different order, that they have been sent. Unreliable messages are also limited by 1024 bytes.

Returns
Type Description
System.Boolean

True if message was sent

UnregisterMessageHandler(UInt16, Action<Byte[]>)

Declaration
void UnregisterMessageHandler(ushort id, Action<byte[]> messageHandler)
Parameters
Type Name Description
System.UInt16 id
System.Action<System.Byte[]> messageHandler

UnregisterSecureMessageHandler(UInt16, Action<UInt16, Byte[], UInt64, Boolean>)

Unsubscribes from incoming messages

Declaration
void UnregisterSecureMessageHandler(ushort id, Action<ushort, byte[], ulong, bool> messageHandler)
Parameters
Type Name Description
System.UInt16 id

Handler id. Should be same that was registered

System.Action<System.UInt16, System.Byte[], System.UInt64, System.Boolean> messageHandler

Call function. Should be same that was registered

☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾