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.SendByChannel<MSG>(short,MSG,int)

Switch to Manual

Parameters

id Message type ID number.
msg Message structure.
channelId Channel to use for sending.

Returns

void True if message is sent.

Description

Send a message structure through the given channel.

The channel should be configured with the tuner in Configure.

#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.SendByChannel(MyMsgTypes.MSG_LOGIN, msg, 0);
	}
}