Interface IServerNetworkAPI
- Namespace
- Vintagestory.API.Server
- Assembly
- VintagestoryAPI.dll
API Features to set up a network channel for custom server<->client data exchange. Server side.
public interface IServerNetworkAPI : INetworkAPI
- Extension Methods
Methods
BroadcastArbitraryPacket(byte[], params IServerPlayer[])
Sends a packet data to everyone except given players. This lets you mess with the raw network communication if you know the protocol. Use with caution! For normal network communication you probably want to register your own network channel.
void BroadcastArbitraryPacket(byte[] data, params IServerPlayer[] exceptPlayers)
Parameters
databyte[]exceptPlayersIServerPlayer[]
BroadcastArbitraryPacket(object, params IServerPlayer[])
(for internal use: packet should be a Packet_Server)
void BroadcastArbitraryPacket(object packet, params IServerPlayer[] exceptPlayers)
Parameters
packetobjectexceptPlayersIServerPlayer[]
BroadcastBlockEntityPacket(BlockPos, int, byte[])
Broadcasts a blockentity packet to all connected players. For quick an easy network communication without setting up a channel first.
void BroadcastBlockEntityPacket(BlockPos pos, int packetId, byte[] data = null)
Parameters
BroadcastBlockEntityPacket(BlockPos, int, byte[], params IServerPlayer[])
void BroadcastBlockEntityPacket(BlockPos pos, int packetId, byte[] data = null, params IServerPlayer[] skipPlayers)
Parameters
posBlockPospacketIdintdatabyte[]skipPlayersIServerPlayer[]
BroadcastBlockEntityPacket<T>(BlockPos, int, T)
Broadcasts a blockentity packet to all connected players. For quick an easy network communication without setting up a channel first. Uses ProtoBuf.net to serialize the data.
void BroadcastBlockEntityPacket<T>(BlockPos pos, int packetId, T data = default)
Parameters
Type Parameters
T
BroadcastEntityPacket(long, int, byte[])
Sends a entity packet to all players in range. For quick an easy entity network communication without setting up a channel first.
void BroadcastEntityPacket(long entityid, int packetId, byte[] data = null)
Parameters
GetChannel(string)
Returns a previously registered channeled, null otherwise
IServerNetworkChannel GetChannel(string channelName)
Parameters
channelNamestring
Returns
GetUdpChannel(string)
Returns a previously registered channeled, null otherwise
IServerNetworkChannel GetUdpChannel(string channelName)
Parameters
channelNamestring
Returns
RegisterChannel(string)
Supplies you with your very own and personal network channel that you can use to send packets across the network. Use the same channelName on the client and server to have them link up.
IServerNetworkChannel RegisterChannel(string channelName)
Parameters
channelNamestringUnique channel identifier
Returns
RegisterUdpChannel(string)
Supplies you with your very own and personal network channel that you can use to send packets across the network. Use the same channelName on the client and server to have them link up. Do not send larger messages then 508 bytes since some clients may be behind NAT/firwalls that may drop your packets if they get fragmented
IServerNetworkChannel RegisterUdpChannel(string channelName)
Parameters
channelNamestringUnique channel identifier
Returns
SendArbitraryPacket(byte[], params IServerPlayer[])
Sends a packet data to given players. This lets you mess with the raw network communication if you know the protocol. Use with caution! For normal network communication you probably want to register your own network channel.
void SendArbitraryPacket(byte[] data, params IServerPlayer[] players)
Parameters
databyte[]playersIServerPlayer[]
SendArbitraryPacket(object, params IServerPlayer[])
(for internal use: packet should be a Packet_Server)
void SendArbitraryPacket(object packet, params IServerPlayer[] players)
Parameters
packetobjectplayersIServerPlayer[]
SendBlockEntityPacket(IServerPlayer, BlockPos, int, byte[])
Sends a blockentity packet to the given player. For quick an easy network communication without setting up a channel first.
void SendBlockEntityPacket(IServerPlayer player, BlockPos pos, int packetId, byte[] data = null)
Parameters
playerIServerPlayerposBlockPospacketIdintdatabyte[]
SendBlockEntityPacket<T>(IServerPlayer, BlockPos, int, T)
Sends a blockentity packet to the given player. For quick an easy network communication without setting up a channel first. Uses ProtoBuf.net to serialize the data.
void SendBlockEntityPacket<T>(IServerPlayer player, BlockPos pos, int packetId, T data = default)
Parameters
playerIServerPlayerposBlockPospacketIdintdataT
Type Parameters
T
SendEntityPacket(IServerPlayer, long, int, byte[])
Sends a entity packet to the given player and entity. For quick an easy entity network communication without setting up a channel first.
void SendEntityPacket(IServerPlayer player, long entityid, int packetId, byte[] data = null)
Parameters
playerIServerPlayerentityidlongpacketIdintdatabyte[]