Networking
Functions
Accept All New Connections
Accept new connections for all servers.
Return Type: Boolean
Signatures:
bool accept_all_new_connections()
public static bool SplashKit.AcceptAllNewConnections();
def accept_all_new_connections():
function AcceptAllNewConnections(): Boolean
Accept New Connection
Accept new connections for a server
Parameters:
Name | Type | Description |
---|---|---|
server | Server Socket | The server to check |
Return Type: Boolean
Signatures:
bool accept_new_connection(server_socket server)
public bool ServerSocket.AcceptNewConnection();public static bool SplashKit.AcceptNewConnection(ServerSocket server);
def accept_new_connection(server):
function AcceptNewConnection(server: ServerSocket): Boolean
Broadcast Message
Broadcast Message
Broadcast a message to all connections of a server.
Parameters:
Name | Type | Description |
---|---|---|
a_msg | String | The message to send |
svr | Server Socket | The server to send the message to. |
Signatures:
void broadcast_message(const string &a_msg, server_socket svr)
public void ServerSocket.BroadcastMessage(string aMsg);public static void SplashKit.BroadcastMessage(string aMsg, ServerSocket svr);
def broadcast_message(a_msg, svr):
procedure BroadcastMessage(const aMsg: String; svr: ServerSocket)
Broadcast Message
Broadcase a message to all of the connections.
Parameters:
Name | Type | Description |
---|---|---|
a_msg | String | The message to send |
Signatures:
void broadcast_message(const string &a_msg)
public static void SplashKit.BroadcastMessage(string aMsg);
def broadcast_message_to_all(a_msg):
procedure BroadcastMessage(const aMsg: String)
Broadcast Message
Broadcast a message to all connections of a server.
Parameters:
Name | Type | Description |
---|---|---|
a_msg | String | The message to send |
name | String | The name of the server to send the message to. |
Signatures:
void broadcast_message(const string &a_msg, const string &name)
public static void SplashKit.BroadcastMessage(string aMsg, string name);
def broadcast_message_to_server_named(a_msg, name):
procedure BroadcastMessage(const aMsg: String; const name: String)
Check Network Activity
Check network activity, looking for new connections and messages.
Signatures:
void check_network_activity()
public static void SplashKit.CheckNetworkActivity();
def check_network_activity():
procedure CheckNetworkActivity()
Clear Messages
Clear Messages
Clear all of the messages from a server or connection with the supplied name.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection or the server to clear. |
Signatures:
void clear_messages(const string &name)
public static void SplashKit.ClearMessages(string name);
def clear_messages_from_name(name):
procedure ClearMessages(const name: String)
Clear Messages
Clear all of the messages from a connection.
Parameters:
Name | Type | Description |
---|---|---|
a_connection | Connection | The connection |
Signatures:
void clear_messages(connection a_connection)
public void Connection.ClearMessages();public static void SplashKit.ClearMessages(Connection aConnection);
def clear_messages_from_connection(a_connection):
procedure ClearMessages(aConnection: Connection)
Clear Messages
Clear all of the messages from a server.
Parameters:
Name | Type | Description |
---|---|---|
svr | Server Socket | The server to clear the messages from |
Signatures:
void clear_messages(server_socket svr)
public void ServerSocket.ClearMessages();public static void SplashKit.ClearMessages(ServerSocket svr);
def clear_messages_from_server(svr):
procedure ClearMessages(svr: ServerSocket)
Close All Connections
Close all of the connections you have opened. This does not close connections to servers.
Signatures:
void close_all_connections()
public static void SplashKit.CloseAllConnections();
def close_all_connections():
procedure CloseAllConnections()
Close All Servers
Close all of the servers that are currently open.
Signatures:
void close_all_servers()
public static void SplashKit.CloseAllServers();
def close_all_servers():
procedure CloseAllServers()
Close Connection
Close Connection
Close the connection
Parameters:
Name | Type | Description |
---|---|---|
a_connection | Connection | The connection to close |
Return Type: Boolean
Signatures:
bool close_connection(connection a_connection)
public bool Connection.Close();public static bool SplashKit.CloseConnection(Connection aConnection);
def close_connection(a_connection):
function CloseConnection(aConnection: Connection): Boolean
Close Connection
Close the connection
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection to close |
Return Type: Boolean
Signatures:
bool close_connection(const string &name)
public static bool SplashKit.CloseConnection(string name);
def close_connection_named(name):
function CloseConnection(const name: String): Boolean
Close Message
Closes the message.
Parameters:
Name | Type | Description |
---|---|---|
msg | Message | The message to close |
Signatures:
void close_message(message msg)
public void Message.Close();public static void SplashKit.CloseMessage(Message msg);
def close_message(msg):
procedure CloseMessage(msg: Message)
Close Server
Close Server
Closes the server with the indicated name.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the server to close |
Return Type: Boolean
Signatures:
bool close_server(const string &name)
public static bool SplashKit.CloseServer(string name);
def close_server_named(name):
function CloseServer(const name: String): Boolean
Close Server
Closes the server, all connections with clients will be shut and the port will be closed.
Parameters:
Name | Type | Description |
---|---|---|
svr | Server Socket | The server to close |
Return Type: Boolean
Signatures:
bool close_server(server_socket svr)
public bool ServerSocket.Close();public static bool SplashKit.CloseServer(ServerSocket svr);
def close_server(svr):
function CloseServer(svr: ServerSocket): Boolean
Connection Count
Connection Count
Returns the number of clients connected to a server.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the server to check |
Return Type: Unsigned Integer
Signatures:
unsigned int connection_count(const string &name)
public static uint SplashKit.ConnectionCount(string name);
def connection_count_named(name):
function ConnectionCount(const name: String): Cardinal
Connection Count
Returns the number of clients connected to a server.
Parameters:
Name | Type | Description |
---|---|---|
server | Server Socket | The server to check |
Return Type: Unsigned Integer
Signatures:
unsigned int connection_count(server_socket server)
public uint ServerSocket.ConnectionCount { get }public static uint SplashKit.ConnectionCount(ServerSocket server);
def connection_count(server):
function ConnectionCount(server: ServerSocket): Cardinal
Connection Ip
Connection Ip
Gets the ip address of the passed in connection.
Parameters:
Name | Type | Description |
---|---|---|
a_connection | Connection | The connection |
Return Type: Unsigned Integer
Signatures:
unsigned int connection_ip(connection a_connection)
public uint Connection.IP { get }public static uint SplashKit.ConnectionIP(Connection aConnection);
def connection_ip(a_connection):
function ConnectionIP(aConnection: Connection): Cardinal
Connection Ip
Gets the ip address of the connection with the supplied name.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection |
Return Type: Unsigned Integer
Signatures:
unsigned int connection_ip(const string &name)
public static uint SplashKit.ConnectionIP(string name);
def connection_ip_from_name(name):
function ConnectionIP(const name: String): Cardinal
Connection Named
Fetch the connection with the indicated name.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection to fetch |
Return Type: Connection
Signatures:
connection connection_named(const string &name)
public static Connection SplashKit.ConnectionNamed(string name);
def connection_named(name):
function ConnectionNamed(const name: String): Connection
Connection Port
Connection Port
Gets the port of the connection.
Parameters:
Name | Type | Description |
---|---|---|
a_connection | Connection | The connection |
Return Type: undefined
Signatures:
unsigned short connection_port(connection a_connection)
public ushort Connection.Port { get }public static ushort SplashKit.ConnectionPort(Connection aConnection);
def connection_port(a_connection):
function ConnectionPort(aConnection: Connection): Word
Connection Port
Gets the part of the connection.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection |
Return Type: undefined
Signatures:
unsigned short connection_port(const string &name)
public static ushort SplashKit.ConnectionPort(string name);
def connection_port_from_name(name):
function ConnectionPort(const name: String): Word
Create Server
Create Server
Creates a new TCP server that can accept connections from other programs.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name used to access the Server in splashkit |
port | unsigned short | The port that clients will use to connect to the server |
Return Type: Server Socket
Signatures:
server_socket create_server(const string &name, unsigned short port)
public static ServerSocket SplashKit.CreateServer(string name, ushort port);public ServerSocket(string name, ushort port);
def create_server_with_port(name, port):
function CreateServer(const name: String; port: Word): ServerSocket
Create Server
Creates a new server that can accept connections from other programs.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name used to access the Server in splashkit |
port | unsigned short | The port that clients will use to connect to the server |
protocol | Connection Type | The protocol used by the server |
Return Type: Server Socket
Signatures:
server_socket create_server(const string &name, unsigned short port, connection_type protocol)
public static ServerSocket SplashKit.CreateServer(string name, ushort port, ConnectionType protocol);public ServerSocket(string name, ushort port, ConnectionType protocol);
def create_server_with_port_and_protocol(name, port, protocol):
function CreateServer(const name: String; port: Word; protocol: ConnectionType): ServerSocket
Dec To Hex
Converts the supplied decimal integer into it’s hexadecimal representation. e.g. 0x7F000001 from 2130706433
Parameters:
Name | Type | Description |
---|---|---|
a_dec | unsigned int | decimal to be converted to a hexadecimal number string |
Return Type: String
Signatures:
string dec_to_hex(unsigned int a_dec)
public static string SplashKit.DecToHex(uint aDec);
def dec_to_hex(a_dec):
function DecToHex(aDec: Cardinal): String
Usage:
Dec To Ipv4
Decodes the supplied unsigned 32-bit integer into its ipv4 address form e.g. 2130706433 into 127.0.0.1
Parameters:
Name | Type | Description |
---|---|---|
ip | unsigned int | integer to be decoded |
Return Type: String
Signatures:
string dec_to_ipv4(unsigned int ip)
public static string SplashKit.DecToIpv4(uint ip);
def dec_to_ipv4(ip):
function DecToIpv4(ip: Cardinal): String
Fetch New Connection
Get the oldest new connections made to the server, and reduces the new connection count by 1.
Parameters:
Name | Type | Description |
---|---|---|
server | Server Socket | The server to check |
Return Type: Connection
Signatures:
connection fetch_new_connection(server_socket server)
public Connection ServerSocket.FetchNewConnection();public static Connection SplashKit.FetchNewConnection(ServerSocket server);
def fetch_new_connection(server):
function FetchNewConnection(server: ServerSocket): Connection
Has Connection
Does the connection with the supplied name exist?
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection to check. |
Return Type: Boolean
Signatures:
bool has_connection(const string &name)
public static bool SplashKit.HasConnection(string name);
def has_connection(name):
function HasConnection(const name: String): Boolean
Has Messages
Has Messages
Checks if there are any messages waiting to be read.
Return Type: Boolean
Signatures:
bool has_messages()
public static bool Networking.HasMessages { get }public static bool SplashKit.HasMessages();
def has_messages():
function HasMessages(): Boolean
Has Messages
Checks if a connection has messages waiting to be read.
Parameters:
Name | Type | Description |
---|---|---|
con | Connection | The connection |
Return Type: Boolean
Signatures:
bool has_messages(connection con)
public bool Connection.HasMessages { get }public static bool SplashKit.HasMessages(Connection con);
def has_messages_on_connection(con):
function HasMessages(con: Connection): Boolean
Has Messages
Checks if a server or connection has any messages.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the server or connection to check. |
Return Type: Boolean
Signatures:
bool has_messages(const string &name)
public static bool SplashKit.HasMessages(string name);
def has_messages_on_name(name):
function HasMessages(const name: String): Boolean
Has Messages
Checks if a server has any messages waiting to be read.
Parameters:
Name | Type | Description |
---|---|---|
svr | Server Socket | The server to check |
Return Type: Boolean
Signatures:
bool has_messages(server_socket svr)
public bool ServerSocket.HasMessages { get }public static bool SplashKit.HasMessages(ServerSocket svr);
def has_messages_on_server(svr):
function HasMessages(svr: ServerSocket): Boolean
Has New Connections
Checks if any of the servers have new connections.
Return Type: Boolean
Signatures:
bool has_new_connections()
public static bool SplashKit.HasNewConnections();
def has_new_connections():
function HasNewConnections(): Boolean
Has Server
Checks if there is a server with the indicated name.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the server to check |
Return Type: Boolean
Signatures:
bool has_server(const string &name)
public static bool SplashKit.HasServer(string name);
def has_server(name):
function HasServer(const name: String): Boolean
Hex Str To Ipv4
The supplied hexadecimal string is translated into ipv4 standard address string. Function handles hex strings starting with or without 0x. e.g. 127.0.0.1 from 0x7F000001
Parameters:
Name | Type | Description |
---|---|---|
a_hex | String | hexadecimal ipv4 string to convert |
Return Type: String
Signatures:
string hex_str_to_ipv4(const string &a_hex)
public static string SplashKit.HexStrToIpv4(string aHex);
def hex_str_to_ipv4(a_hex):
function HexStrToIpv4(const aHex: String): String
Hex To Dec String
The supplied hexadecimal string is converted into it’s decimal representation e.g. 7F into 127
Parameters:
Name | Type | Description |
---|---|---|
a_hex | String | hexadecimal string to convert |
Return Type: String
Signatures:
string hex_to_dec_string(const string &a_hex)
public static string SplashKit.HexToDecString(string aHex);
def hex_to_dec_string(a_hex):
function HexToDecString(const aHex: String): String
Usage:
Ipv4 To Dec
Encodes the supplied ipv4 address string (in format X.X.X.X) into a single integer e.g. 127.0.0.1 into 2130706433
Parameters:
Name | Type | Description |
---|---|---|
a_ip | String | ipv4 address to encode |
Return Type: Unsigned Integer
Signatures:
unsigned int ipv4_to_dec(const string &a_ip)
public static uint SplashKit.Ipv4ToDec(string aIP);
def ipv4_to_dec(a_ip):
function Ipv4ToDec(const aIP: String): Cardinal
Usage:
Ipv4 To Hex
Converts an ipv4 address into it’s hexadecimal representation e.g. 0x7F000001 from 127.0.0.1
Parameters:
Name | Type | Description |
---|---|---|
a_ip | String | ip address to convert |
Return Type: String
Signatures:
string ipv4_to_hex(const string &a_ip)
public static string SplashKit.Ipv4ToHex(string aIP);
def ipv4_to_hex(a_ip):
function Ipv4ToHex(const aIP: String): String
Usage:
Is Connection Open
Is Connection Open
Checks if the connection currently is open.
Parameters:
Name | Type | Description |
---|---|---|
con | Connection | The connection |
Return Type: Boolean
Signatures:
bool is_connection_open(connection con)
public bool Connection.IsOpen { get }public static bool SplashKit.IsConnectionOpen(Connection con);
def is_connection_open(con):
function IsConnectionOpen(con: Connection): Boolean
Is Connection Open
Checks if the connection with the supplied name currently is open.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection |
Return Type: Boolean
Signatures:
bool is_connection_open(const string &name)
public static bool SplashKit.IsConnectionOpen(string name);
def is_connection_open_from_name(name):
function IsConnectionOpen(const name: String): Boolean
Is Valid Ipv4
Parameters:
Name | Type | Description |
---|---|---|
ip | String | The string containing the IP address to validate |
Return Type: Boolean
Signatures:
bool is_valid_ipv4(const string &ip)
public static bool SplashKit.IsValidIpv4(string ip);
def is_valid_ipv4(ip):
function IsValidIpv4(const ip: String): Boolean
Last Connection
Last Connection
Gets the last client that connected to a server.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the server to check |
Return Type: Connection
Signatures:
connection last_connection(const string &name)
public static Connection SplashKit.LastConnection(string name);
def last_connection_named(name):
function LastConnection(const name: String): Connection
Last Connection
Gets the last client that connected to a server.
Parameters:
Name | Type | Description |
---|---|---|
server | Server Socket | The server to check |
Return Type: Connection
Signatures:
connection last_connection(server_socket server)
public Connection ServerSocket.LastConnection { get }public static Connection SplashKit.LastConnection(ServerSocket server);
def last_connection(server):
function LastConnection(server: ServerSocket): Connection
Message Connection
Returns the connection that sent a message.
Parameters:
Name | Type | Description |
---|---|---|
msg | Message | The message |
Return Type: Connection
Signatures:
connection message_connection(message msg)
public static Connection SplashKit.MessageConnection(Message msg);
def message_connection(msg):
function MessageConnection(msg: Message): Connection
Message Count
Message Count
Returns the number of messages on a server.
Parameters:
Name | Type | Description |
---|---|---|
svr | Server Socket | The server to check |
Return Type: Unsigned Integer
Signatures:
unsigned int message_count(server_socket svr)
public uint ServerSocket.MessageCount { get }public static uint SplashKit.MessageCount(ServerSocket svr);
def message_count_on_server(svr):
function MessageCount(svr: ServerSocket): Cardinal
Message Count
Returns the number of messages on a connection.
Parameters:
Name | Type | Description |
---|---|---|
a_connection | Connection | The connection |
Return Type: Unsigned Integer
Signatures:
unsigned int message_count(connection a_connection)
public uint Connection.MessageCount { get }public static uint SplashKit.MessageCount(Connection aConnection);
def message_count_on_connection(a_connection):
function MessageCount(aConnection: Connection): Cardinal
Message Count
Returns the number of messages on a server or connection.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the server or connection |
Return Type: Unsigned Integer
Signatures:
unsigned int message_count(const string &name)
public static uint SplashKit.MessageCount(string name);
def message_count_from_name(name):
function MessageCount(const name: String): Cardinal
Message Data
Gets the body of a message as a string.
Parameters:
Name | Type | Description |
---|---|---|
msg | Message | The message to check |
Return Type: String
Signatures:
string message_data(message msg)
public string Message.Data { get }public static string SplashKit.MessageData(Message msg);
def message_data(msg):
function MessageData(msg: Message): String
Message Data Bytes
Gets the body of a message as a list of bytes.
Parameters:
Name | Type | Description |
---|---|---|
msg | Message | The message to check |
Return Type: Vector
Signatures:
vector<int8_t> message_data_bytes(message msg)
public List<byte> Message.DataBytes { get }public static List<byte> SplashKit.MessageDataBytes(Message msg);
def message_data_bytes(msg):
function MessageDataBytes(msg: Message): ArrayOfChar
Message Host
Returns the host who made the message.
Parameters:
Name | Type | Description |
---|---|---|
msg | Message | The message to check |
Return Type: String
Signatures:
string message_host(message msg)
public string Message.Host { get }public static string SplashKit.MessageHost(Message msg);
def message_host(msg):
function MessageHost(msg: Message): String
Message Port
Returns the port used to send a message.
Parameters:
Name | Type | Description |
---|---|---|
msg | Message | The message to check |
Return Type: undefined
Signatures:
unsigned short message_port(message msg)
public ushort Message.Port { get }public static ushort SplashKit.MessagePort(Message msg);
def message_port(msg):
function MessagePort(msg: Message): Word
Message Protocol
Returns the protocol used to send a message.
Parameters:
Name | Type | Description |
---|---|---|
msg | Message | The message to check |
Return Type: Connection Type
Signatures:
connection_type message_protocol(message msg)
public ConnectionType Message.Protocol { get }public static ConnectionType SplashKit.MessageProtocol(Message msg);
def message_protocol(msg):
function MessageProtocol(msg: Message): ConnectionType
My Ip
Returns the ipv4 string of the localhost loopback for the current computer.
Return Type: String
Signatures:
string my_ip()
public static string SplashKit.MyIP();
def my_ip():
function MyIP(): String
Name For Connection
Returns the name SplashKit would use for a connection made to a server from a host to a port.
Parameters:
Name | Type | Description |
---|---|---|
host | String | The host name |
port | unsigned int | The port |
Return Type: String
Signatures:
string name_for_connection(const string host, const unsigned int port)
public static string SplashKit.NameForConnection(string host, uint port);
def name_for_connection(host, port):
function NameForConnection(host: String; port: Cardinal): String
New Connection Count
Get the number of new connections made to the server. The count will increase as the server accepts new connections. The count decreases each time you fetch a new connection, or can be set to 0 if you reset the new connection count.
Parameters:
Name | Type | Description |
---|---|---|
server | Server Socket | The server to check |
Return Type: Integer
Signatures:
int new_connection_count(server_socket server)
public int ServerSocket.NewConnectionCount { get }public static int SplashKit.NewConnectionCount(ServerSocket server);
def new_connection_count(server):
function NewConnectionCount(server: ServerSocket): Integer
Open Connection
Open Connection
Opens a TCP connection to a server using the supplied details.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name for the connection |
host | String | The address of the server |
port | unsigned short | The server’s port |
Return Type: Connection
Signatures:
connection open_connection(const string &name, const string &host, unsigned short port)
public static Connection SplashKit.OpenConnection(string name, string host, ushort port);public Connection(string name, string host, ushort port);
def open_connection(name, host, port):
function OpenConnection(const name: String; const host: String; port: Word): Connection
Open Connection
Opens a connection to a server using the supplied details.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name for the connection |
host | String | The address of the server |
port | unsigned short | The server’s port |
protocol | Connection Type | The protocol used to connect to the server |
Return Type: Connection
Signatures:
connection open_connection(const string &name, const string &host, unsigned short port, connection_type protocol)
public static Connection SplashKit.OpenConnection(string name, string host, ushort port, ConnectionType protocol);public Connection(string name, string host, ushort port, ConnectionType protocol);
def open_connection_with_protocol(name, host, port, protocol):
function OpenConnection(const name: String; const host: String; port: Word; protocol: ConnectionType): Connection
Read Message
Read Message
Read a message from the network (from a server or connection).
Return Type: Message
Signatures:
message read_message()
public static Message SplashKit.ReadMessage();
def read_message():
function ReadMessage(): Message
Read Message
Reads the first message from the connection.
Parameters:
Name | Type | Description |
---|---|---|
a_connection | Connection | A connection |
Return Type: Message
Signatures:
message read_message(connection a_connection)
public Message Connection.ReadMessage();public static Message SplashKit.ReadMessage(Connection aConnection);
def read_message_from_connection(a_connection):
function ReadMessage(aConnection: Connection): Message
Read Message
Reads the first message from a connection or server.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of a connection or server |
Return Type: Message
Signatures:
message read_message(const string &name)
public static Message SplashKit.ReadMessage(string name);
def read_message_from_name(name):
function ReadMessage(const name: String): Message
Read Message
Reads the first message from the server.
Parameters:
Name | Type | Description |
---|---|---|
svr | Server Socket | A server |
Return Type: Message
Signatures:
message read_message(server_socket svr)
public Message ServerSocket.ReadMessage();public static Message SplashKit.ReadMessage(ServerSocket svr);
def read_message_from_server(svr):
function ReadMessage(svr: ServerSocket): Message
Read Message Data
Read Message Data
Read message data from a connection or server.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection or server |
Return Type: String
Signatures:
string read_message_data(const string &name)
public static string SplashKit.ReadMessageData(string name);
def read_message_data_from_name(name):
function ReadMessageData(const name: String): String
Read Message Data
Read message data from a connection.
Parameters:
Name | Type | Description |
---|---|---|
a_connection | Connection | The connection |
Return Type: String
Signatures:
string read_message_data(connection a_connection)
public string Connection.ReadMessageData();public static string SplashKit.ReadMessageData(Connection aConnection);
def read_message_data_from_connection(a_connection):
function ReadMessageData(aConnection: Connection): String
Read Message Data
Read message data from a server.
Parameters:
Name | Type | Description |
---|---|---|
svr | Server Socket | The server |
Return Type: String
Signatures:
string read_message_data(server_socket svr)
public string ServerSocket.ReadMessageData();public static string SplashKit.ReadMessageData(ServerSocket svr);
def read_message_data_from_server(svr):
function ReadMessageData(svr: ServerSocket): String
Reconnect
Reconnect
Attempt to reconnect the connection.
Parameters:
Name | Type | Description |
---|---|---|
a_connection | Connection | The connection to reconnect |
Signatures:
void reconnect(connection a_connection)
public void Connection.Reconnect();public static void SplashKit.Reconnect(Connection aConnection);
def reconnect(a_connection):
procedure Reconnect(aConnection: Connection)
Reconnect
Attempt to reconnect the connection.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the connection to reconnect. |
Signatures:
void reconnect(const string &name)
public static void SplashKit.Reconnect(string name);
def reconnect_from_name(name):
procedure Reconnect(const name: String)
Release All Connections
Close and release the resources used by all of the connections.
Signatures:
void release_all_connections()
public static void SplashKit.ReleaseAllConnections();
def release_all_connections():
procedure ReleaseAllConnections()
Reset New Connection Count
Allows you to reset the new connection count to 0. (The connections are kept)
Parameters:
Name | Type | Description |
---|---|---|
server | Server Socket | The server to check |
Signatures:
void reset_new_connection_count(server_socket server)
public void ServerSocket.ResetNewConnectionCount();public static void SplashKit.ResetNewConnectionCount(ServerSocket server);
def reset_new_connection_count(server):
procedure ResetNewConnectionCount(server: ServerSocket)
Retrieve Connection
Retrieve Connection
Get a connection from the server.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the server |
idx | Integer | The index of the connection |
Return Type: Connection
Signatures:
connection retrieve_connection(const string &name, int idx)
public static Connection SplashKit.RetrieveConnection(string name, int idx);
def retrieve_connection_named(name, idx):
function RetrieveConnection(const name: String; idx: Integer): Connection
Retrieve Connection
Get a connection from the server.
Parameters:
Name | Type | Description |
---|---|---|
server | Server Socket | The server |
idx | Integer | The index of the connection |
Return Type: Connection
Signatures:
connection retrieve_connection(server_socket server, int idx)
public Connection ServerSocket.RetrieveConnection(int idx);public static Connection SplashKit.RetrieveConnection(ServerSocket server, int idx);
def retrieve_connection(server, idx):
function RetrieveConnection(server: ServerSocket; idx: Integer): Connection
Send Message To
Send Message To
Send a message to the connection.
Parameters:
Name | Type | Description |
---|---|---|
a_msg | String | The message to send |
a_connection | Connection | The connection to send the message to |
Return Type: Boolean
Signatures:
bool send_message_to(const string &a_msg, connection a_connection)
public bool Connection.SendMessage(string aMsg);public static bool SplashKit.SendMessageTo(string aMsg, Connection aConnection);
def send_message_to_connection(a_msg, a_connection):
function SendMessageTo(const aMsg: String; aConnection: Connection): Boolean
Send Message To
Send a message to the connection with the given name.
Parameters:
Name | Type | Description |
---|---|---|
a_msg | String | The message to send |
name | String | The name of the connection to send the message to |
Return Type: Boolean
Signatures:
bool send_message_to(const string &a_msg, const string &name)
public static bool SplashKit.SendMessageTo(string aMsg, string name);
def send_message_to_name(a_msg, name):
function SendMessageTo(const aMsg: String; const name: String): Boolean
Server Has New Connection
Server Has New Connection
Checks of there are new connections waiting for a server.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the server to check |
Return Type: Boolean
Signatures:
bool server_has_new_connection(const string &name)
public static bool SplashKit.ServerHasNewConnection(string name);
def server_has_new_connection_named(name):
function ServerHasNewConnection(const name: String): Boolean
Server Has New Connection
Checks of there are new connections waiting for a server.
Parameters:
Name | Type | Description |
---|---|---|
server | Server Socket | The server to check |
Return Type: Boolean
Signatures:
bool server_has_new_connection(server_socket server)
public bool ServerSocket.HasNewConnections { get }public static bool SplashKit.ServerHasNewConnection(ServerSocket server);
def server_has_new_connection(server):
function ServerHasNewConnection(server: ServerSocket): Boolean
Server Named
Gets the server with the indicated name.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the server to get |
Return Type: Server Socket
Signatures:
server_socket server_named(const string &name)
public static ServerSocket SplashKit.ServerNamed(string name);
def server_named(name):
function ServerNamed(const name: String): ServerSocket
Set Udp Packet Size
Change the size of the UDP packets.
Parameters:
Name | Type | Description |
---|---|---|
udp_packet_size | unsigned int | The new packet size. |
Signatures:
void set_udp_packet_size(unsigned int udp_packet_size)
public static void Networking.UDPPacketSize { set }public static void SplashKit.SetUDPPacketSize(uint udpPacketSize);
def set_udp_packet_size(udp_packet_size):
procedure SetUDPPacketSize(udpPacketSize: Cardinal)
Udp Packet Size
Returns the size SplashKit is using for UDP packets.
Return Type: Unsigned Integer
Signatures:
unsigned int udp_packet_size()
public static uint Networking.UDPPacketSize { get }public static uint SplashKit.UDPPacketSize();
def udp_packet_size():
function UDPPacketSize(): Cardinal
Download Bitmap
Download an image from a web server and load it into SplashKit so that you can use it.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the bitmap resource when it is loaded |
url | String | The URL path to the image resoure |
port | unsigned short | The port to connect to on the server |
Return Type: Bitmap
Signatures:
bitmap download_bitmap(const string &name, const string &url, unsigned short port)
public static Bitmap SplashKit.DownloadBitmap(string name, string url, ushort port);
def download_bitmap(name, url, port):
function DownloadBitmap(const name: String; const url: String; port: Word): Bitmap
Download Font
Download a font from a web server and load it into SplashKit so that you can use it.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the font resource when it is loaded |
url | String | The URL path to the font resoure |
port | unsigned short | The port to connect to on the server |
Return Type: Font
Signatures:
font download_font(const string &name, const string &url, unsigned short port)
public static Font SplashKit.DownloadFont(string name, string url, ushort port);
def download_font(name, url, port):
function DownloadFont(const name: String; const url: String; port: Word): Font
Download Music
Download a music file from a web server and load it into SplashKit so that you can use it.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the music resource when it is loaded |
url | String | The URL path to the music resoure |
port | unsigned short | The port to connect to on the server |
Return Type: Music
Signatures:
music download_music(const string &name, const string &url, unsigned short port)
public static Music SplashKit.DownloadMusic(string name, string url, ushort port);
def download_music(name, url, port):
function DownloadMusic(const name: String; const url: String; port: Word): Music
Download Sound Effect
Download a sound effect from a web server and load it into SplashKit so that you can use it.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the sound effect resource when it is loaded |
url | String | The URL path to the sound effect resoure |
port | unsigned short | The port to connect to on the server |
Return Type: Sound Effect
Signatures:
sound_effect download_sound_effect(const string &name, const string &url, unsigned short port)
public static SoundEffect SplashKit.DownloadSoundEffect(string name, string url, ushort port);
def download_sound_effect(name, url, port):
function DownloadSoundEffect(const name: String; const url: String; port: Word): SoundEffect
Free Response
Free the response resource.
Parameters:
Name | Type | Description |
---|---|---|
response | Http Response | The response to free |
Signatures:
void free_response(http_response response)
public void HttpResponse.Free();public static void SplashKit.FreeResponse(HttpResponse response);
def free_response(response):
procedure FreeResponse(response: HttpResponse)
Usage:
Http Get
Make a get request to access a resource on the internet.
Parameters:
Name | Type | Description |
---|---|---|
url | String | The path to the resource, for example http://splashkit.io |
port | unsigned short | The port on the server (80 for http, 443 for https) |
Return Type: Http Response
Signatures:
http_response http_get(const string &url, unsigned short port)
public static HttpResponse SplashKit.HttpGet(string url, ushort port);
def http_get(url, port):
function HttpGet(const url: String; port: Word): HttpResponse
Usage:
Http Post
Http Post
Post the supplied information to the indicated url with the given headers.
Parameters:
Name | Type | Description |
---|---|---|
url | String | The url of the server to post the data to |
port | unsigned short | The port to connect to on the server |
body | String | The body of the message to post |
headers | Vector | The headers of the request |
Return Type: Http Response
Signatures:
http_response http_post(const string &url, unsigned short port, const string &body, const vector<string> &headers)
public static HttpResponse SplashKit.HttpPost(string url, ushort port, string body, List<string> headers);
def http_post_with_headers(url, port, body, headers):
function HttpPost(const url: String; port: Word; const body: String; const headers: ArrayOfString): HttpResponse
Usage:
Http Post
Post the supplied information to the indicated url.
Parameters:
Name | Type | Description |
---|---|---|
url | String | The url of the server to post the data to |
port | unsigned short | The port to connect to on the server |
body | String | The body of the message to post |
Return Type: Http Response
Signatures:
http_response http_post(const string &url, unsigned short port, string body)
public static HttpResponse SplashKit.HttpPost(string url, ushort port, string body);
def http_post(url, port, body):
function HttpPost(const url: String; port: Word; body: String): HttpResponse
Http Response To String
Read the HTTP response and convert it to text
Parameters:
Name | Type | Description |
---|---|---|
response | Http Response | The response from the server |
Return Type: String
Signatures:
string http_response_to_string(http_response response)
public static string SplashKit.HttpResponseToString(HttpResponse response);
def http_response_to_string(response):
function HttpResponseToString(response: HttpResponse): String
Usage:
Save Response To File
Save the HTTP response downloaded into a file.
Parameters:
Name | Type | Description |
---|---|---|
response | Http Response | The response from the server |
path | String | The path to the file where the response should be saved |
Signatures:
void save_response_to_file(http_response response, string path)
public static void SplashKit.SaveResponseToFile(HttpResponse response, string path);
def save_response_to_file(response, path):
procedure SaveResponseToFile(response: HttpResponse; path: String)
Has Incoming Requests
Returns true if the given web_sever
has pending requests.
Parameters:
Name | Type | Description |
---|---|---|
server | Web Server | The Web Server to check for waiting requests. |
Return Type: Boolean
Signatures:
bool has_incoming_requests(web_server server)
public bool WebServer.HasIncomingRequests { get }public static bool SplashKit.HasIncomingRequests(WebServer server);
def has_incoming_requests(server):
function HasIncomingRequests(server: WebServer): Boolean
Is Delete Request For
Checks if a request wants to delete a given resource.
Parameters:
Name | Type | Description |
---|---|---|
request | Http Request | The request to check |
path | String | The resource/route path |
Return Type: Boolean
Signatures:
bool is_delete_request_for(http_request request, const string &path)
public bool HttpRequest.IsDeleteRequestFor(string path);public static bool SplashKit.IsDeleteRequestFor(HttpRequest request, string path);
def is_delete_request_for(request, path):
function IsDeleteRequestFor(request: HttpRequest; const path: String): Boolean
Is Get Request For
Checks if a request wants to get a given resource.
Parameters:
Name | Type | Description |
---|---|---|
request | Http Request | The request to check |
path | String | The resource/route path |
Return Type: Boolean
Signatures:
bool is_get_request_for(http_request request, const string &path)
public bool HttpRequest.IsGetRequestFor(string path);public static bool SplashKit.IsGetRequestFor(HttpRequest request, string path);
def is_get_request_for(request, path):
function IsGetRequestFor(request: HttpRequest; const path: String): Boolean
Usage:
Is Options Request For
Checks if a request wants to check options for given resource.
Parameters:
Name | Type | Description |
---|---|---|
request | Http Request | The request to check |
path | String | The resource/route path |
Return Type: Boolean
Signatures:
bool is_options_request_for(http_request request, const string &path)
public bool HttpRequest.IsOptionsRequestFor(string path);public static bool SplashKit.IsOptionsRequestFor(HttpRequest request, string path);
def is_options_request_for(request, path):
function IsOptionsRequestFor(request: HttpRequest; const path: String): Boolean
Is Post Request For
Checks if a request wants to create (post) a given resource.
Parameters:
Name | Type | Description |
---|---|---|
request | Http Request | The request to check |
path | String | The resource/route path |
Return Type: Boolean
Signatures:
bool is_post_request_for(http_request request, const string &path)
public bool HttpRequest.IsPostRequestFor(string path);public static bool SplashKit.IsPostRequestFor(HttpRequest request, string path);
def is_post_request_for(request, path):
function IsPostRequestFor(request: HttpRequest; const path: String): Boolean
Is Put Request For
Checks if a request wants to update (put) a given resource.
Parameters:
Name | Type | Description |
---|---|---|
request | Http Request | The request to check |
path | String | The resource/route path |
Return Type: Boolean
Signatures:
bool is_put_request_for(http_request request, const string &path)
public bool HttpRequest.IsPutRequestFor(string path);public static bool SplashKit.IsPutRequestFor(HttpRequest request, string path);
def is_put_request_for(request, path):
function IsPutRequestFor(request: HttpRequest; const path: String): Boolean
Is Request For
Checks if a request is after a given resource.
Parameters:
Name | Type | Description |
---|---|---|
request | Http Request | The request to check |
method | Http Method | The kind of request |
path | String | The resource/route path |
Return Type: Boolean
Signatures:
bool is_request_for(http_request request, http_method method, const string &path)
public bool HttpRequest.IsRequestFor(HttpMethod method, string path);public static bool SplashKit.IsRequestFor(HttpRequest request, HttpMethod method, string path);
def is_request_for(request, method, path):
function IsRequestFor(request: HttpRequest; method: HttpMethod; const path: String): Boolean
Is Trace Request For
Checks if a request wants to trace a given resource.
Parameters:
Name | Type | Description |
---|---|---|
request | Http Request | The request to check |
path | String | The resource/route path |
Return Type: Boolean
Signatures:
bool is_trace_request_for(http_request request, const string &path)
public bool HttpRequest.IsTraceRequestFor(string path);public static bool SplashKit.IsTraceRequestFor(HttpRequest request, string path);
def is_trace_request_for(request, path):
function IsTraceRequestFor(request: HttpRequest; const path: String): Boolean
Next Web Request
Returns the next request on a given Web Server
instance
Parameters:
Name | Type | Description |
---|---|---|
server | Web Server | The Web Server to get the Http Request from. |
Return Type: Http Request
Signatures:
http_request next_web_request(web_server server)
public HttpRequest WebServer.NextWebRequest { get }public static HttpRequest SplashKit.NextWebRequest(WebServer server);
def next_web_request(server):
function NextWebRequest(server: WebServer): HttpRequest
Usage:
Request Body
Returns the body of the request.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | A request object. |
Return Type: String
Signatures:
string request_body(http_request r)
public string HttpRequest.Body { get }public static string SplashKit.RequestBody(HttpRequest r);
def request_body(r):
function RequestBody(r: HttpRequest): String
Request Has Query Parameter
Returns true if the parameter exists in the query string.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | A request object. |
name | String | The name of the parameter to check |
Return Type: Boolean
Signatures:
bool request_has_query_parameter(http_request r, const string &name)
public bool HttpRequest.HasQueryParameter(string name);public static bool SplashKit.RequestHasQueryParameter(HttpRequest r, string name);
def request_has_query_parameter(r, name):
function RequestHasQueryParameter(r: HttpRequest; const name: String): Boolean
Request Headers
Returns the headers of the request.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | A request object. |
Return Type: Vector
Signatures:
vector<string> request_headers(http_request r)
public List<string> HttpRequest.Headers { get }public static List<string> SplashKit.RequestHeaders(HttpRequest r);
def request_headers(r):
function RequestHeaders(r: HttpRequest): ArrayOfString
Request Method
Returns the HTTP method of the client request.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | A request object. |
Return Type: Http Method
Signatures:
http_method request_method(http_request r)
public HttpMethod HttpRequest.Method { get }public static HttpMethod SplashKit.RequestMethod(HttpRequest r);
def request_method(r):
function RequestMethod(r: HttpRequest): HttpMethod
Request Query Parameter
Returns the value of a parameter from within the query string, or the supplied default if no matching parameter is found.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | A request object. |
name | String | The name of the parameter to fetch |
default_value | String | The value to return if the named parameter is not in the query string. |
Return Type: String
Signatures:
string request_query_parameter(http_request r, const string &name, const string &default_value)
public string HttpRequest.QueryParameter(string name, string defaultValue);public static string SplashKit.RequestQueryParameter(HttpRequest r, string name, string defaultValue);
def request_query_parameter(r, name, default_value):
function RequestQueryParameter(r: HttpRequest; const name: String; const defaultValue: String): String
Request Query String
Returns the URI query string of the client request.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | A request object. |
Return Type: String
Signatures:
string request_query_string(http_request r)
public string HttpRequest.QueryString { get }public static string SplashKit.RequestQueryString(HttpRequest r);
def request_query_string(r):
function RequestQueryString(r: HttpRequest): String
Request Uri
Returns the server URI of the client request.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | A request object. |
Return Type: String
Signatures:
string request_uri(http_request r)
public string HttpRequest.URI { get }public static string SplashKit.RequestURI(HttpRequest r);
def request_uri(r):
function RequestURI(r: HttpRequest): String
Request Uri Stubs
Returns an array of strings representing each stub of the URI. For example a request sent to http://localhost:8080/names/0
returns… [“names”, “0”]
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The request for retrieving URI to split into stubs. |
Return Type: Vector
Signatures:
vector<string> request_uri_stubs(http_request r)
public List<string> HttpRequest.URIStubs { get }public static List<string> SplashKit.RequestURIStubs(HttpRequest r);
def request_uri_stubs(r):
function RequestURIStubs(r: HttpRequest): ArrayOfString
Send Css File Response
Serves a css file to the given Http Request
.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The request which is asking for the resource. |
filename | String | The name of the file in Resources/server |
Signatures:
void send_css_file_response(http_request r, const string &filename)
public void HttpRequest.SendCSSFileResponse(string filename);public static void SplashKit.SendCSSFileResponse(HttpRequest r, string filename);
def send_css_file_response(r, filename):
procedure SendCSSFileResponse(r: HttpRequest; const filename: String)
Send File Response
Serves a file to the given Http Request
.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The request which is asking for the resource. |
filename | String | The name of the file in Resources/server |
content_type | String | The type of content being send: |
Signatures:
void send_file_response(http_request r, const string &filename, const string &content_type)
public void HttpRequest.SendFileResponse(string filename, string contentType);public static void SplashKit.SendFileResponse(HttpRequest r, string filename, string contentType);
def send_file_response(r, filename, content_type):
procedure SendFileResponse(r: HttpRequest; const filename: String; const contentType: String)
Send Html File Response
Serves a HTML file to the given Http Request
.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The request which is asking for the resource. |
filename | String | The name of the file in Resources/server |
Signatures:
void send_html_file_response(http_request r, const string &filename)
public void HttpRequest.SendHtmlFileResponse(string filename);public static void SplashKit.SendHtmlFileResponse(HttpRequest r, string filename);
def send_html_file_response(r, filename):
procedure SendHtmlFileResponse(r: HttpRequest; const filename: String)
Usage:
Send Javascript File Response
Serves a javascript file to the given Http Request
.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The request which is asking for the resource. |
filename | String | The name of the file in Resources/server |
Signatures:
void send_javascript_file_response(http_request r, const string &filename)
public void HttpRequest.SendJavascriptFileResponse(string filename);public static void SplashKit.SendJavascriptFileResponse(HttpRequest r, string filename);
def send_javascript_file_response(r, filename):
procedure SendJavascriptFileResponse(r: HttpRequest; const filename: String)
Send Response
Send Response
Sends a response with no content to a Http Request
.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The Http Request to send the response to |
Signatures:
void send_response(http_request r)
public void HttpRequest.SendResponse();public static void SplashKit.SendResponse(HttpRequest r);
def send_response_empty(r):
procedure SendResponse(r: HttpRequest)
Send Response
Sends a message to a given Http Request
.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The request to be sent. |
message | String | The message to be sent |
Signatures:
void send_response(http_request r, const string &message)
public void HttpRequest.SendResponse(string message);public static void SplashKit.SendResponse(HttpRequest r, string message);
def send_response(r, message):
procedure SendResponse(r: HttpRequest; const message: String)
Usage:
Send Response
Sends a response code to a given Http Request
.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The Http Request to send the response to |
code | Http Status Code | The [HTTP status code](See https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) to be sent. |
Signatures:
void send_response(http_request r, http_status_code code)
public void HttpRequest.SendResponse(HttpStatusCode code);public static void SplashKit.SendResponse(HttpRequest r, HttpStatusCode code);
def send_response_json_with_status(r, code):
procedure SendResponse(r: HttpRequest; code: HttpStatusCode)
Send Response
Sends a message to a given Http Request
with the specified content type.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The Http Request to send the response to |
code | Http Status Code | The [HTTP status code](See https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) to be sent. |
message | String | The messsage, in the form of a Http Response , to be sent. |
Signatures:
void send_response(http_request r, http_status_code code, const string &message)
public void HttpRequest.SendResponse(HttpStatusCode code, string message);public static void SplashKit.SendResponse(HttpRequest r, HttpStatusCode code, string message);
def send_response_with_status(r, code, message):
procedure SendResponse(r: HttpRequest; code: HttpStatusCode; const message: String)
Send Response
Sends a message to a given Http Request
with the specified content type.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The Http Request to send the response to |
code | Http Status Code | The [HTTP status code](See https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) to be sent. |
message | String | The messsage, in the form of a Http Response , to be sent. |
content_type | String | The content type of the response. |
Signatures:
void send_response(http_request r, http_status_code code, const string &message, const string &content_type)
public void HttpRequest.SendResponse(HttpStatusCode code, string message, string contentType);public static void SplashKit.SendResponse(HttpRequest r, HttpStatusCode code, string message, string contentType);
def send_response_with_status_and_content_type(r, code, message, content_type):
procedure SendResponse(r: HttpRequest; code: HttpStatusCode; const message: String; const contentType: String)
Send Response
Sends a message to a given Http Request
with the specified content type.
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The Http Request to send the response to |
code | Http Status Code | The [HTTP status code](See https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) to be sent. |
message | String | The messsage, in the form of a Http Response , to be sent. |
content_type | String | The content type of the response. |
headers | Vector | The response headers |
Signatures:
void send_response(http_request r, http_status_code code, const string &message, const string &content_type, const vector<string> &headers)
public void HttpRequest.SendResponse(HttpStatusCode code, string message, string contentType, List<string> headers);public static void SplashKit.SendResponse(HttpRequest r, HttpStatusCode code, string message, string contentType, List<string> headers);
def send_response_with_status_and_content_type_and_headers(r, code, message, content_type, headers):
procedure SendResponse(r: HttpRequest; code: HttpStatusCode; const message: String; const contentType: String; const headers: ArrayOfString)
Send Response
Send a JSON response to a given Http Request
Parameters:
Name | Type | Description |
---|---|---|
r | Http Request | The request the response belongs to. |
j | Json | The json to be sent. |
Signatures:
void send_response(http_request r, json j)
public void HttpRequest.SendResponse(Json j);public static void SplashKit.SendResponse(HttpRequest r, Json j);
def send_response_json(r, j):
procedure SendResponse(r: HttpRequest; j: Json)
Split Uri Stubs
Returns an array of strings representing each stub of the URI. For example a request sent to http://localhost:8080/names/0
returns… [“names”, “0”]
Parameters:
Name | Type | Description |
---|---|---|
uri | String | The URI to split into stubs. |
Return Type: Vector
Signatures:
vector<string> split_uri_stubs(const string &uri)
public static List<string> SplashKit.SplitURIStubs(string uri);
def split_uri_stubs(uri):
function SplitURIStubs(const uri: String): ArrayOfString
Start Web Server
Start Web Server
Creates a new web server listening for connections on port 8080.
Return Type: Web Server
Signatures:
web_server start_web_server()
public static WebServer SplashKit.StartWebServer();public WebServer();
def start_web_server_with_default_port():
function StartWebServer(): WebServer
Usage:
Start Web Server
Starts the web server on a given port number.
Parameters:
Name | Type | Description |
---|---|---|
port | unsigned short | The port number to connect through. |
Return Type: Web Server
Signatures:
web_server start_web_server(unsigned short port)
public static WebServer SplashKit.StartWebServer(ushort port);public WebServer(ushort port);
def start_web_server(port):
function StartWebServer(port: Word): WebServer
Stop Web Server
Stops a given Web Server
instance.
Parameters:
Name | Type | Description |
---|---|---|
server | Web Server | The server instance to stop. |
Signatures:
void stop_web_server(web_server server)
public void WebServer.Stop();public static void SplashKit.StopWebServer(WebServer server);
def stop_web_server(server):
procedure StopWebServer(server: WebServer)
Usage:
Types
Connection
A connection represents the communication channel from a client going to a server. This can be used for the client and the server to send and receive messages.
Connection Type
Constant | Description |
---|---|
TCP | Uses the TCP protocol. SplashKit can send messages of anysize, and repackage it from you at the other end. Messagesare reliably transferred. |
UDP | Uses the UDP protocol. SplashKit will send messages of upto 1024 bytes (by default). You need to handle packaginganything larger than this. |
UNKNOWN | The protocol is unknown, usually due to the connectionor server being invalid or closed. |
Constant | Description |
---|---|
ConnectionType.TCP | Uses the TCP protocol. SplashKit can send messages of anysize, and repackage it from you at the other end. Messagesare reliably transferred. |
ConnectionType.UDP | Uses the UDP protocol. SplashKit will send messages of upto 1024 bytes (by default). You need to handle packaginganything larger than this. |
ConnectionType.Unknown | The protocol is unknown, usually due to the connectionor server being invalid or closed. |
Constant | Description |
---|---|
connection_type.tcp | Uses the TCP protocol. SplashKit can send messages of anysize, and repackage it from you at the other end. Messagesare reliably transferred. |
connection_type.udp | Uses the UDP protocol. SplashKit will send messages of upto 1024 bytes (by default). You need to handle packaginganything larger than this. |
connection_type.unknown | The protocol is unknown, usually due to the connectionor server being invalid or closed. |
Constant | Description |
---|---|
ConnectionType.TCP | Uses the TCP protocol. SplashKit can send messages of anysize, and repackage it from you at the other end. Messagesare reliably transferred. |
ConnectionType.UDP | Uses the UDP protocol. SplashKit will send messages of upto 1024 bytes (by default). You need to handle packaginganything larger than this. |
ConnectionType.Unknown | The protocol is unknown, usually due to the connectionor server being invalid or closed. |
The kind of protocol used for a server of connection.
Http Method
Constant | Description |
---|---|
HTTP_GET_METHOD | A get method |
HTTP_POST_METHOD | A post method |
HTTP_PUT_METHOD | A put method |
HTTP_DELETE_METHOD | A delete method |
HTTP_OPTIONS_METHOD | An options method |
HTTP_TRACE_METHOD | A trace method |
UNKNOWN_HTTP_METHOD | A method not recognised by SplashKit |
Constant | Description |
---|---|
HttpMethod.HttpGetMethod | A get method |
HttpMethod.HttpPostMethod | A post method |
HttpMethod.HttpPutMethod | A put method |
HttpMethod.HttpDeleteMethod | A delete method |
HttpMethod.HttpOptionsMethod | An options method |
HttpMethod.HttpTraceMethod | A trace method |
HttpMethod.UnknownHttpMethod | A method not recognised by SplashKit |
Constant | Description |
---|---|
http_method.http_get_method | A get method |
http_method.http_post_method | A post method |
http_method.http_put_method | A put method |
http_method.http_delete_method | A delete method |
http_method.http_options_method | An options method |
http_method.http_trace_method | A trace method |
http_method.unknown_http_method | A method not recognised by SplashKit |
Constant | Description |
---|---|
HttpMethod.HttpGetMethod | A get method |
HttpMethod.HttpPostMethod | A post method |
HttpMethod.HttpPutMethod | A put method |
HttpMethod.HttpDeleteMethod | A delete method |
HttpMethod.HttpOptionsMethod | An options method |
HttpMethod.HttpTraceMethod | A trace method |
HttpMethod.UnknownHttpMethod | A method not recognised by SplashKit |
The method token is used to indicate the kind of action to be performed on the server. See W3 specifications.
Http Request
The request contains the details of the resource the user is requesting.
Http Response
A HTTP response is a resource that comes back from a HTTP request. This
may be the text related to a web page, or the data related to a resource.
Once you have used the response, you need to make sure to call
Free Response
.
Message
A message contains data that has been transferred between a client connection and a server (or visa versa).
Server Socket
A server represents a network resource that clients can connect to. The server will receive messages from all of the client connections, and can be used to access the clients connected to the server.
Web Server
The web server is able to listen for incoming requests, and you can then provide the response.