Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

NetworkClient.SendUnreliable<MSG>(short,MSG)

Switch to Manual

Parameters

id Message type ID number.
msg Message structure.

Returns

void True if message is sent.

Description

Send given message structure as an unreliable message.

#pragma strict
public class MyMsgTypes {
	public static var MSG_LOGIN: short = 51;
	public static var MSG_START: short = 52;
}
public class LoginMessage extends System.ValueType {
	public var myName: String;
}
class GameClient {
	var myClient: NetworkClient;
	GameClient {
		myClient = new NetworkClient();
		myClient.Connect("localhost", 55555);
		myClient.RegisterHandler(MsgType.SYSTEM_CONNECT, OnConnected);
	}
	public function OnConnected(conn: NetworkConnection, reader: NetworkReader) {
		myClient.Ready();
		var msg: LoginMessage;
		msg.myName = "SomeGuy";
		myClient.SendUnreliable(MyMsgTypes.MSG_LOGIN, msg);
	}
}