Banner Image

Module Utilities.Socket

Utilities - Socket.

Main Features:

  • Creates UDP Sockets
  • Send messages to Discord
  • Compatible with FunkMan
  • Compatible with DCSServerBot

Author: funkyfranky

Global(s)

Global SOCKET

At times I feel like a socket that remembers its tooth. -- Saul Bellow


The SOCKET Concept

Create a UDP socket server.

#SOCKET SOCKET

At times I feel like a socket that remembers its tooth. -- Saul Bellow


The SOCKET Concept

Create a UDP socket server.

It enables you to send messages to discord servers via discord bots.

Note that you have to de-sanitize require and package in your MissionScripting.lua file, which is in your DCS/Scripts folder.

Type(s)

SOCKET , extends Core.Fsm#FSM
Fields and Methods inherited from SOCKET Description

SOCKET.ClassName

Name of the class.

SOCKET.DataType

SOCKET:New(Port, Host)

Create a new SOCKET object.

SOCKET:SendTable(Table)

Send a table.

SOCKET:SendText(Text)

Send a text message.

SOCKET:SendTextToSpeech(Text, Provider, Voice, Culture, Gender, Volume)

Send a text-to-speech message.

SOCKET:SetHost(Host)

Set host.

SOCKET:SetPort(Port)

Set port.

SOCKET.UDPSendSocket

SOCKET.host

The host.

SOCKET.json

JSON.

SOCKET.lid

Class id string for output to DCS log file.

SOCKET.port

The port.

SOCKET.socket

The socket.

SOCKET.verbose

Verbosity level.

SOCKET.version

SOCKET class version.

Fields and Methods inherited from FSM Description

SOCKET:AddEndState(State)

Adds an End state.

SOCKET:AddProcess(From, Event, Process, ReturnEvents)

Set the default #FSM_PROCESS template with key ProcessName providing the ProcessClass and the process object when it is assigned to a Wrapper.Controllable by the task.

SOCKET:AddScore(State, ScoreText, Score)

Adds a score for the FSM to be achieved.

SOCKET:AddScoreProcess(From, Event, State, ScoreText, Score)

Adds a score for the FSM_PROCESS to be achieved.

SOCKET:AddTransition(From, Event, To)

Add a new transition rule to the FSM.

SOCKET.CallScheduler

SOCKET.Events

SOCKET:GetCurrentState()

Get current state.

SOCKET:GetEndStates()

Returns the End states.

SOCKET:GetProcess(From, Event)

SOCKET:GetProcesses()

Returns a table of the SubFSM rules defined within the FSM.

SOCKET:GetScores()

Returns a table with the scores defined.

SOCKET:GetStartState()

Returns the start state of the FSM.

SOCKET:GetState()

Get current state.

SOCKET:GetSubs()

Returns a table with the Subs defined.

SOCKET:GetTransitions()

Returns a table of the transition rules defined within the FSM.

SOCKET:Is(State)

Check if FSM is in state.

SOCKET:LoadCallBacks(CallBackTable)

Load call backs.

SOCKET:New()

Creates a new FSM object.

SOCKET.Scores

SOCKET:SetProcess(From, Event, Fsm)

SOCKET:SetStartState(State)

Sets the start state of the FSM.

SOCKET._EndStates

SOCKET._EventSchedules

SOCKET._Processes

SOCKET._Scores

SOCKET._StartState

SOCKET._Transitions

SOCKET:_add_to_map(Map, Event)

Add to map.

SOCKET:_call_handler(step, trigger, params, EventName)

Call handler.

SOCKET:_create_transition(EventName)

Create transition.

SOCKET:_delayed_transition(EventName)

Delayed transition.

SOCKET:_eventmap(Events, EventStructure)

Event map.

SOCKET:_gosub(ParentFrom, ParentEvent)

Go sub.

SOCKET:_handler(EventName, ...)

Handler.

SOCKET:_isendstate(Current)

Is end state.

SOCKET:_submap(subs, sub, name)

Sub maps.

SOCKET:can(e)

Check if can do an event.

SOCKET:cannot(e)

Check if cannot do an event.

SOCKET.current

SOCKET.endstates

SOCKET:is(State, state)

Check if FSM is in state.

SOCKET.options

SOCKET.subs

Fields and Methods inherited from SOCKET.DataType Description

SOCKET.DataType.BOMBRESULT

Range bombing.

SOCKET.DataType.LSOGRADE

Airboss LSO grade.

SOCKET.DataType.STRAFERESULT

Range strafeing result.

SOCKET.DataType.TEXT

Plain text.

SOCKET.DataType.TTS

Text-To-Speech.

SOCKET class.

Field(s)

#string SOCKET.ClassName

Name of the class.

#string SOCKET.host

The host.

#table SOCKET.json

JSON.

#string SOCKET.lid

Class id string for output to DCS log file.

#number SOCKET.port

The port.

#table SOCKET.socket

The socket.

#number SOCKET.verbose

Verbosity level.

#string SOCKET.version

SOCKET class version.

Function(s)

Create a new SOCKET object.

Defined in:

SOCKET

Parameters:

#number Port

UDP port. Default 10042.

#string Host

Host. Default "127.0.0.1".

Return value:

self

Send a table.

Defined in:

SOCKET

Parameter:

#table Table

Table to send.

Return value:

self

Send a text message.

Defined in:

SOCKET

Parameter:

#string Text

Text message.

Return value:

self

Send a text-to-speech message.

Defined in:

SOCKET

Parameters:

#string Text

The text message to speek.

#number Provider

The TTS provider: 0=Microsoft (default), 1=Google.

#string Voice

The specific voice to use, e.g. "Microsoft David Desktop" or "en-US-Standard-A". If not set, the service will choose a voice based on the other parameters such as culture and gender.

#string Culture

The Culture or language code, e.g. "en-US".

#string Gender

The Gender, i.e. "male", "female". Default "female".

#number Volume

The volume. Microsoft: [0,100] default 50, Google: [-96, 10] default 0.

Return value:

self

Set host.

Defined in:

SOCKET

Parameter:

#string Host

Host. Default "127.0.0.1".

Return value:

self

Set port.

Defined in:

SOCKET

Parameter:

#number Port

Port. Default 10042.

Return value:

self

Field(s)

#string SOCKET.ClassName

Name of the class.

#string SOCKET.host

The host.

#table SOCKET.json

JSON.

#string SOCKET.lid

Class id string for output to DCS log file.

#number SOCKET.port

The port.

#table SOCKET.socket

The socket.

#number SOCKET.verbose

Verbosity level.

#string SOCKET.version

SOCKET class version.

Function(s)

Adds an End state.

Defined in:

Parameter:

#string State

The FSM state.

Set the default #FSM_PROCESS template with key ProcessName providing the ProcessClass and the process object when it is assigned to a Wrapper.Controllable by the task.

Defined in:

Parameters:

#table From

Can contain a string indicating the From state or a table of strings containing multiple From states.

#string Event

The Event name.

An sub-process FSM.

#table ReturnEvents

A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.

Return value:

The SubFSM.

Adds a score for the FSM to be achieved.

Defined in:

Parameters:

#string State

is the state of the process when the score needs to be given. (See the relevant state descriptions of the process).

#string ScoreText

is a text describing the score that is given according the status.

#number Score

is a number providing the score of the status.

Return value:

#FSM:

self

Adds a score for the FSM_PROCESS to be achieved.

Defined in:

Parameters:

#string From

is the From State of the main process.

#string Event

is the Event of the main process.

#string State

is the state of the process when the score needs to be given. (See the relevant state descriptions of the process).

#string ScoreText

is a text describing the score that is given according the status.

#number Score

is a number providing the score of the status.

Return value:

#FSM:

self

Add a new transition rule to the FSM.

A transition rule defines when and if the FSM can transition from a state towards another state upon a triggered event.

Defined in:

Parameters:

#table From

Can contain a string indicating the From state or a table of strings containing multiple From states.

#string Event

The Event name.

#string To

The To state.

Get current state.

Defined in:

Return value:

#string:

Current FSM state.

Returns the End states.

Defined in:

Return value:

#table:

End states.

Defined in:

Parameters:

From

Event

Returns a table of the SubFSM rules defined within the FSM.

Defined in:

Return value:

#table:

Sub processes.

Returns a table with the scores defined.

Defined in:

Return value:

#table:

Scores.

Returns the start state of the FSM.

Defined in:

Return value:

#string:

A string containing the start state.

Get current state.

Defined in:

Return value:

#string:

Current FSM state.

Returns a table with the Subs defined.

Defined in:

Return value:

#table:

Sub processes.

Returns a table of the transition rules defined within the FSM.

Defined in:

Return value:

#table:

Transitions.

Check if FSM is in state.

Defined in:

Parameter:

#string State

State name.

Return value:

#boolean:

If true, FSM is in this state.

Load call backs.

Defined in:

Parameter:

#table CallBackTable

Table of call backs.

Creates a new FSM object.

Defined in:

Return value:

#FSM:

Defined in:

Parameters:

From

Event

Fsm

Sets the start state of the FSM.

Defined in:

Parameter:

#string State

A string defining the start state.

Add to map.

Defined in:

Parameters:

#table Map

Map.

#table Event

Event table.

Call handler.

Defined in:

Parameters:

#string step

Step "onafter", "onbefore", "onenter", "onleave".

#string trigger

Trigger.

#table params

Parameters.

#string EventName

Event name.

Return value:

Value.

Create transition.

Defined in:

Parameter:

#string EventName

Event name.

Return value:

#function:

Function.

Delayed transition.

Defined in:

Parameter:

#string EventName

Event name.

Return value:

#function:

Function.

Event map.

Defined in:

Parameters:

#table Events

Events.

#table EventStructure

Event structure.

Go sub.

Defined in:

Parameters:

#string ParentFrom

Parent from state.

#string ParentEvent

Parent event name.

Return value:

#table:

Subs.

Handler.

Defined in:

Parameters:

#string EventName

Event name.

...

Arguments.

Is end state.

Defined in:

Parameter:

#string Current

Current state name.

Return values:

#table:

FSM parent.

#string:

Event name.

Sub maps.

Defined in:

Parameters:

#table subs

Subs.

#table sub

Sub.

#string name

Name.

Check if can do an event.

Defined in:

Parameter:

#string e

Event name.

Return values:

#boolean:

If true, FSM can do the event.

#string:

To state.

Check if cannot do an event.

Defined in:

Parameter:

#string e

Event name.

Return value:

#boolean:

If true, FSM cannot do the event.

Check if FSM is in state.

Defined in:

Parameters:

#string State

State name.

state

Return value:

#boolean:

If true, FSM is in this state.

Data type.

This is the keyword the socket listener uses.

Field(s)

#string SOCKET.DataType.BOMBRESULT

Range bombing.

#string SOCKET.DataType.LSOGRADE

Airboss LSO grade.

#string SOCKET.DataType.STRAFERESULT

Range strafeing result.

#string SOCKET.DataType.TEXT

Plain text.

#string SOCKET.DataType.TTS

Text-To-Speech.

Function(s)