InSim Relay: различия между версиями

Материал из LFS Manual.
Перейти к навигацииПерейти к поиску
Строка 1: Строка 1:
== Информация ==
+
== InSim Relay usage information ==
 
+
The InSim Relay is a service that can connect to your LFS host via InSim and relay the InSim information sent by your host, to anyone who connects to the InSim Relay. This relayed data can be used by programmers for various things, such as the LFS Remote (remote viewing / adminning of a race) and race-tracking to store race information and statistics.
В этом разделе написано руководство о том, как подключиться к InSim с использованием различных языков программирования.  
 
Есть много пакетов заранее скомпилированного программного обеспечения (например, JInSim для Java, FullMotion.LiveForSpeed на C # и так далее), но вы даже не узнаете, как использовать, если InSim Вы используете скомпилированным пакетов. Таким образом, каждая секция на этой странице должна быть на одном языке программирования и должна содержать следующие подразделы:
 
 
 
# Тип
 
# Построение/разборка пакета
 
# Соединение с InSim
 
# Отсоединение от InSim
 
# Пример
 
  
 +
To have your host connected to the Relay, see this page on LFS World:
 +
http://www.lfsworld.net/?win=hosts&whichTab=insim_relay
  
 +
The rest of this document is only for programmers who want to know how to connect to the InSim Relay, so they can make use of the available data.<br>
  
== Использование InSim Relay (С/С++)==
+
=== Connecting to the InSim Relay ===
InSim Relay - это сервис, который подлючается к игровому серверу LFS через InSim и передает InSim информацию любому, кто подключится через InSim Relay. Эта передоваемая информация может использоваться программистами для различных целей, таких как LFS Spectator (удаленный просмотр гонок) и отслеживания и хранения статистики.
+
The Relay code below can be seen as an extension to the regular InSim protocol, as the packets are constructed in the same manner as regular InSim packets and use their own identifiers.
  
Чтобы подключить ваш сервер к Insim Relay, запишите его в базу на LFS World:
+
Connect your client to isrelay.lfs.net:47474 with TCP. After you are connected you can request a list of hosts, so you can see which hosts you can connect to. Then you can send a packet to the Relay to select a host. After that the Relay will send you all insim data from that host.
http://www.lfsworld.net/?win=hosts&whichTab=insim_relay
 
  
Остальная часть этого документа только для программистов, которые хотят знать, как связаться с InSim Relay, с тем чтобы они могли использовать имеющиеся данные.<br>
+
Some hosts require a spectator password in order to be selectable.
  
+
You do not need to specify a spectator password if you use a valid administrator password.
NEW: теперь вы можете также подключать различные другие insim Моды через relay,потому что вы можете подключиться к серверу с паролем администратора. Смотрите в конце этого документа какие пакеты можно послать.
 
  
=== Поключение к InSim Relay ===
+
If you connect with an administrator password, you can send just about every regular InSim packet there is available in LFS, just like as if you were connected to the host directly. For a full list, see end of document.
Протокол, используемый для Relay - TCP и подключается к серверу isrelay.liveforspeed.net (213.40.20.2) через порт 47474
 
  
Приведем данные из документации
+
=== Packet types used for the Relay ===
  
 
<pre>
 
<pre>
// InSimRelay for LFS InSim version 4 (LFS 0.5X and up)
+
#define IRP_ARQ 250 // Send : request if we are host admin (after connecting to a host)
//
+
#define IRP_ARP 251 // Receive : replies if you are admin (after connecting to a host)
// The Relay code below can be seen as an extension to the regular
 
// InSim protocol, as the packets are constructed in the same
 
// manner as regular InSim packets.
 
//
 
// Connect your client to isrelay.lfs.net:47474 with TCP
 
// After you are connected you can request a hostlist, so you can see
 
// which hosts you can connect to.
 
// Then you can send a packet to the Relay to select a host. After that
 
// the Relay will send you all insim data from that host.
 
 
 
// Some hosts require a spectator password in order to be selectable.
 
 
 
// You do not need to specify a spectator password if you use a valid administrator password.
 
 
 
// If you connect with an administrator password, you can send just about every
 
// regular InSim packet there is available in LFS, just like as if you were connected
 
// to the host directly. For a full list, see end of document.
 
 
 
 
 
 
 
 
 
// Packet types used for the Relay
 
 
 
#define IRP_HARQ        250    // Receive : Admin mod Request
 
#define IRP_HARS        251    // Send  : Response on IRP_HARQ
 
 
#define IRP_HLR 252 // Send : To request a hostlist
 
#define IRP_HLR 252 // Send : To request a hostlist
 
#define IRP_HOS 253 // Receive : Hostlist info
 
#define IRP_HOS 253 // Receive : Hostlist info
 
#define IRP_SEL 254 // Send : To select a host
 
#define IRP_SEL 254 // Send : To select a host
 
#define IRP_ERR 255 // Receive : An error number
 
#define IRP_ERR 255 // Receive : An error number
 +
</pre>
  
 +
To request a hostlist from the Relay, send this packet :
  
 
+
<pre>
 
 
 
 
// To request a hostlist from the Relay, send this packet :
 
 
 
 
struct IR_HLR // HostList Request
 
struct IR_HLR // HostList Request
 
{
 
{
Строка 74: Строка 39:
 
byte Sp0;
 
byte Sp0;
 
};
 
};
 +
</pre>
  
 +
That will return (multiple) packets containing hostnames and some information about them
  
// That will return (multiple) packets containing hostnames and some information about them
+
The following struct is a sub packet of the IR_HOS packet
 
 
// The following struct is a subpacket of the IR_HOS packet
 
  
 +
<pre>
 
struct HInfo // Sub packet for IR_HOS. Contains host information
 
struct HInfo // Sub packet for IR_HOS. Contains host information
 
{
 
{
Строка 90: Строка 56:
  
 
// NOTE 1)
 
// NOTE 1)
 
 
#define HOS_SPECPASS 1 // Host requires a spectator password
 
#define HOS_SPECPASS 1 // Host requires a spectator password
 
#define HOS_LICENSED 2 // Bit is set if host is licensed
 
#define HOS_LICENSED 2 // Bit is set if host is licensed
 
#define HOS_S1         4 // Bit is set if host is S1
 
#define HOS_S1         4 // Bit is set if host is S1
 
#define HOS_S2         8 // Bit is set if host is S2
 
#define HOS_S2         8 // Bit is set if host is S2
 +
</pre>
  
 
+
<pre>
 
struct IR_HOS // Hostlist (hosts connected to the Relay)
 
struct IR_HOS // Hostlist (hosts connected to the Relay)
 
{
 
{
Строка 106: Строка 72:
 
HInfo Info[6]; // Host info for every host in the Relay. 1 to 6 of these in a IR_HOS
 
HInfo Info[6]; // Host info for every host in the Relay. 1 to 6 of these in a IR_HOS
 
};
 
};
 +
</pre>
  
 +
To select a host in the Relay, send this packet :
  
// To select a host in the Relay, send this packet :
+
<pre>
 
 
 
struct IR_SEL // Relay select - packet to select a host, so relay starts sending you data.
 
struct IR_SEL // Relay select - packet to select a host, so relay starts sending you data.
 
{
 
{
Строка 122: Строка 89:
  
 
};
 
};
 +
</pre>
  
// After connecting, you can check the user to have admin rights
+
To request if we are an admin send:
 
+
<pre>
struct IR_HARQ // Admin Request
+
struct IR_ARQ // Admin Request
 
{
 
{
     byte    Size;       // 4
+
     byte    Size; // 4
     byte    Type;       // IRP_HARQ
+
     byte    Type; // IRP_ARQ
 
     byte    ReqI;
 
     byte    ReqI;
 
     byte    Sp0;
 
     byte    Sp0;
 
};
 
};
 +
</pre>
  
struct IR_HARS // Admin Response
+
Relay will reply to admin status request :
 +
 
 +
<pre>
 +
struct IR_ARP // Admin Response
 
  {
 
  {
    byte   Size;       // 4
+
byte Size; // 4
    byte   Type;       // IRP_HARS
+
byte Type; // IRP_ARP
    byte   ReqI;
+
byte ReqI;
    byte   Admin;     // 0- no admin; 1- admin
+
byte Admin; // 0- no admin; 1- admin
 
  };
 
  };
 +
</pre>
  
 +
If you specify a wrong value, like invalid packet / hostname / adminpass / specpass, the Relay returns an error packet :
  
// If you specify a wrong value, like invalid packet / hostname / adminpass / specpass,
+
<pre>
// the Relay returns an error packet :
 
 
 
 
struct IR_ERR
 
struct IR_ERR
 
{
 
{
Строка 154: Строка 126:
  
 
// NOTE 2) Error numbers :
 
// NOTE 2) Error numbers :
 +
#define IR_ERR_PACKET1          1    // Invalid packet sent by client (wrong structure / length)
 +
#define IR_ERR_PACKET2          2    // Invalid packet sent by client (packet was not allowed to be forwarded to host)
 +
#define IR_ERR_HOSTNAME        3    // Wrong hostname given by client
 +
#define IR_ERR_ADMIN            4    // Wrong admin pass given by client
 +
#define IR_ERR_SPEC            5    // Wrong spec pass given by client
 +
#define IR_ERR_NOSPEC          6    // Spectator pass required, but none given
 +
</pre>
  
#define IR_ERR_PACKET      1  // Invalid packet sent by client (wrong structure / length)
+
<b>Regular insim packets that a relay client can send to host :</b>
#define IR_ERR_PACKET2 2 // Invalid packet sent by client (packet was not allowed to be forwarded to host)
 
#define IR_ERR_HOSTNAME 3 // Wrong hostname given by client
 
#define IR_ERR_ADMIN 4 // Wrong admin pass given by client
 
#define IR_ERR_SPEC 5 // Wrong spec pass given by client
 
#define IR_ERR_NOSPEC          6            // Spectator pass required, but none given
 
  
==============================================
+
For anyone<br>
Regular insim packets that a relay client can send to host :
+
TINY_VER<br>
 +
TINY_PING<br>
 +
TINY_SCP<br>
 +
TINY_SST<br>
 +
TINY_GTH<br>
 +
TINY_ISM<br>
 +
TINY_NCN<br>
 +
TINY_NPL<br>
 +
TINY_RES<br>
 +
TINY_REO<br>
 +
TINY_RST<br>
 +
TINY_AXI<br>
  
For anyone
+
Admin only<br>
TINY_VER
+
TINY_VTC<br>
TINY_PING
+
ISP_MST<br>
TINY_SCP
+
ISP_MSX<br>
TINY_SST
+
ISP_MSL<br>
TINY_GTH
+
ISP_MTC<br>
TINY_ISM
+
ISP_SCH<br>
TINY_NCN
+
ISP_BFN<br>
TINY_NPL
+
ISP_BTN<br>
TINY_RES
 
TINY_REO
 
TINY_RST
 
TINY_AXI
 
  
Admin only
+
The relay will also accept, but not forward<br>
TINY_VTC
+
TINY_NONE    // for relay-connection maintenance
ISP_MST
 
ISP_MSX
 
ISP_MSL
 
ISP_MTC
 
ISP_SCH
 
ISP_BFN
 
ISP_BTN
 
  
The relay will also accept, but not forward
+
=== List of escape codes ===
TINY_NONE    // for relay-connection maintenance
+
 
</pre>
+
^v - |<br>
 +
^a - *<br>
 +
^c - :<br>
 +
^d - \<br>
 +
^s - /<br>
 +
^q - ?<br>
 +
^t - "<br>
 +
^l - <<br>
 +
^r - ><br>
 +
 
 +
^L = Latin 1 (CP1252)<br>
 +
^G = Greek (ISO-8859-7)<br>
 +
^C = Cyrillic (CP1251)<br>
 +
^J = Japanese (Shift-JIS)<br>
 +
^E = Central Europe (ISO-8859-2)<br>
 +
^T = Turkish (ISO-8859-9)<br>
 +
^B = Baltic (ISO-8859-13)<br>
 +
^H = Traditional Chinese (CP936)<br>
 +
^S = Simpified Chinese (CP949)<br>
 +
^K = Korean (CP950)<br>
 +
 
 +
^0 - Black<br>
 +
^1 - Red<br>
 +
^2 - Light green<br>
 +
^3 - Yellow<br>
 +
^4 - Blue<br>
 +
^5 - Purple<br>
 +
^6 - Light blue<br>
 +
^7 - White<br>
 +
^8 - Dark green (default)<br>
 +
^9 - Original text colour and codepage.
 +
 
 +
{{Guides}}
  
 
<!-- links to other languages -->
 
<!-- links to other languages -->
 
[[en:InSim Relay]]
 
[[en:InSim Relay]]

Версия 17:05, 20 августа 2009

InSim Relay usage information

The InSim Relay is a service that can connect to your LFS host via InSim and relay the InSim information sent by your host, to anyone who connects to the InSim Relay. This relayed data can be used by programmers for various things, such as the LFS Remote (remote viewing / adminning of a race) and race-tracking to store race information and statistics.

To have your host connected to the Relay, see this page on LFS World: http://www.lfsworld.net/?win=hosts&whichTab=insim_relay

The rest of this document is only for programmers who want to know how to connect to the InSim Relay, so they can make use of the available data.

Connecting to the InSim Relay

The Relay code below can be seen as an extension to the regular InSim protocol, as the packets are constructed in the same manner as regular InSim packets and use their own identifiers.

Connect your client to isrelay.lfs.net:47474 with TCP. After you are connected you can request a list of hosts, so you can see which hosts you can connect to. Then you can send a packet to the Relay to select a host. After that the Relay will send you all insim data from that host.

Some hosts require a spectator password in order to be selectable.

You do not need to specify a spectator password if you use a valid administrator password.

If you connect with an administrator password, you can send just about every regular InSim packet there is available in LFS, just like as if you were connected to the host directly. For a full list, see end of document.

Packet types used for the Relay

#define IRP_ARQ		250	// Send : request if we are host admin (after connecting to a host)
#define IRP_ARP		251	// Receive : replies if you are admin (after connecting to a host)
#define IRP_HLR		252	// Send : To request a hostlist
#define IRP_HOS		253	// Receive : Hostlist info
#define IRP_SEL		254	// Send : To select a host
#define IRP_ERR		255	// Receive : An error number

To request a hostlist from the Relay, send this packet :

struct IR_HLR // HostList Request
{
	byte	Size;		// 4
	byte	Type;		// IRP_HLR
	byte	ReqI;
	byte	Sp0;
};

That will return (multiple) packets containing hostnames and some information about them

The following struct is a sub packet of the IR_HOS packet

struct HInfo // Sub packet for IR_HOS. Contains host information
{
	char	HName[32];	// Name of the host
	
	char	Track[6];	// Short track name
	byte	Flags;		// Info flags about the host - see NOTE 1) below
	byte	NumConns;	// Number of people on the host
};

// NOTE 1)
#define HOS_SPECPASS		1	// Host requires a spectator password
#define HOS_LICENSED		2	// Bit is set if host is licensed
#define HOS_S1		        4	// Bit is set if host is S1
#define HOS_S2		        8	// Bit is set if host is S2
struct IR_HOS // Hostlist (hosts connected to the Relay)
{
	byte	Size;		// 4 + NumHosts * 40
	byte	Type;		// IRP_HOS
	byte	ReqI;		// As given in IR_HLR
	byte	NumHosts;	// Number of hosts described in this packet

	HInfo	Info[6];	// Host info for every host in the Relay. 1 to 6 of these in a IR_HOS
};

To select a host in the Relay, send this packet :

struct IR_SEL // Relay select - packet to select a host, so relay starts sending you data.
{
	byte	Size;		// 68
	byte	Type;		// IRP_SEL
	byte	ReqI;		// If non-zero Relay will reply with an IS_VER packet
	byte	Zero;		// 0

	char	HName[32];	// Hostname to receive data from - may be colourcode stripped
	char	Admin[16];	// Admin password (to gain admin access to host)
	char	Spec[16];	// Spectator password (if host requires it)

};

To request if we are an admin send:

struct IR_ARQ // Admin Request
{
    byte    Size;		// 4
    byte    Type;		// IRP_ARQ
    byte    ReqI;
    byte    Sp0;
};

Relay will reply to admin status request :

struct IR_ARP // Admin Response
 {
	 byte	Size;		// 4
	 byte	Type;		// IRP_ARP
	 byte	ReqI;
	 byte	Admin;		// 0- no admin; 1- admin
 };

If you specify a wrong value, like invalid packet / hostname / adminpass / specpass, the Relay returns an error packet :

struct IR_ERR
{
	byte	Size;		// 4
	byte	Type;		// IRP_ERR
	byte	ReqI;		// As given in RL_SEL, otherwise 0
	byte	ErrNo;		// Error number - see NOTE 2) below
};

// NOTE 2) Error numbers :
#define IR_ERR_PACKET1          1    // Invalid packet sent by client (wrong structure / length)
#define IR_ERR_PACKET2          2    // Invalid packet sent by client (packet was not allowed to be forwarded to host)
#define IR_ERR_HOSTNAME         3    // Wrong hostname given by client
#define IR_ERR_ADMIN            4    // Wrong admin pass given by client
#define IR_ERR_SPEC             5    // Wrong spec pass given by client
#define IR_ERR_NOSPEC           6    // Spectator pass required, but none given

Regular insim packets that a relay client can send to host :

For anyone
TINY_VER
TINY_PING
TINY_SCP
TINY_SST
TINY_GTH
TINY_ISM
TINY_NCN
TINY_NPL
TINY_RES
TINY_REO
TINY_RST
TINY_AXI

Admin only
TINY_VTC
ISP_MST
ISP_MSX
ISP_MSL
ISP_MTC
ISP_SCH
ISP_BFN
ISP_BTN

The relay will also accept, but not forward
TINY_NONE // for relay-connection maintenance

List of escape codes

^v - |
^a - *
^c - :
^d - \
^s - /
^q - ?
^t - "
^l - <
^r - >

^L = Latin 1 (CP1252)
^G = Greek (ISO-8859-7)
^C = Cyrillic (CP1251)
^J = Japanese (Shift-JIS)
^E = Central Europe (ISO-8859-2)
^T = Turkish (ISO-8859-9)
^B = Baltic (ISO-8859-13)
^H = Traditional Chinese (CP936)
^S = Simpified Chinese (CP949)
^K = Korean (CP950)

^0 - Black
^1 - Red
^2 - Light green
^3 - Yellow
^4 - Blue
^5 - Purple
^6 - Light blue
^7 - White
^8 - Dark green (default)
^9 - Original text colour and codepage.