|
|||||||||
Atavism Version 2018.1 | AGIS API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectatavism.server.engine.EnginePlugin
atavism.server.plugins.VoicePlugin
public class VoicePlugin
Plugin to handle voice channels
Nested Class Summary | |
---|---|
static class |
VoicePlugin.VoiceConManager
A class with locking to manage the Maps and Sets of connections. |
Field Summary | |
---|---|
protected static boolean |
allowVoiceBots
If this is true, we subscribe to login messages and pass on login notifications. |
static boolean |
checkAuthToken
|
static CountLogger.Counter |
countAllocateVoiceReceived
|
static CountLogger.Counter |
countAllocateVoiceSent
|
static CountLogger.Counter |
countDeallocateVoiceReceived
|
static CountLogger.Counter |
countDeallocateVoiceSent
|
static CountLogger.Counter |
countSendLoginStatus
|
protected static boolean |
createGroupWhenReferenced
If this is true, we'll synthesize the group and/or group member when an auth packet comes in. |
static TimeHistogram |
dataSendHistogram
|
protected static float |
hystericalMargin
The hysteresis constant: don't change whether a pair of positonal group members are in-radius of each other if the distance is within this distance of the audibleRadius. |
protected static VoicePlugin |
instance
singleton |
static int |
lengthBytes
There are two bytes in the length prefixed to a TCP message |
protected java.util.concurrent.locks.Lock |
lock
|
static int |
maxVoiceChannels
The server is supposed to run things so no client ever has more than this number of voice channels. |
static byte |
opcodeAggregatedData
An aggregated data packet contains a number of data packets. |
static byte |
opcodeAllocateCodec
Allocate a voice. |
static byte |
opcodeAllocatePositionalCodec
This has exactly the same payload as AllocateCodec, but says that the voice should be positional. |
static byte |
opcodeAuthenticate
The authenticate packet must be the first one received by the voice plugin on any new connection from a client. |
static byte |
opcodeChangeIgnoredStatus
An opcode sent exclusively from the client to the server that marks a collection of oids as ignored or not ignored. |
static byte |
opcodeData
A data packet, consisting of a 4-byte header followed by the bytes of the data frame. |
static byte |
opcodeDeallocate
Deallocate the voice number. |
static int |
opcodeHighest
|
static byte |
opcodeLoginStatus
An opcode sent exclusively from the server to the client, and used only to support synchronization between voice bots and test clients. |
static java.lang.String[] |
opcodeNames
Used in logging messages |
static byte |
opcodeReconfirmCodec
This has exactly the same payload as AllocateCodec, but is with lossy transports like UDP to send the opcode parameters every second or so. |
static byte |
opcodeVoiceUnallocated
All voices start out unallocated |
protected PerceptionFilter |
perceptionFilter
|
protected long |
perceptionSubId
|
static TimeHistogram |
processPacketHistogram
|
static boolean |
runHistograms
|
protected boolean |
running
|
static int[] |
speexNarrowBandFrameSize
This array is indexed by Speex narrow-band mode, and gives the narrow-band frame size for that mode. |
static int[] |
speexWideBandFrameSize
|
protected atavism.server.plugins.VoicePlugin.Updater |
updater
|
protected java.lang.Thread |
updaterThread
|
static TimeHistogram |
voiceAllocHistogram
|
static TimeHistogram |
voiceDeallocHistogram
|
static int[] |
voiceMsgSize
This gives the number of bytes in the message excluding the length, except for the data case, where it gives the number of bytes in the header, but not including the data itself |
static byte |
voicePacketHeaderSize
All voice packets start with 4 bytes: o 16-bit sequence number, increased by one for each successive transmission for this voice. |
Fields inherited from interface atavism.msgsys.MessageCallback |
---|
NO_FLAGS, RESPONSE_EXPECTED |
Constructor Summary | |
---|---|
VoicePlugin()
The VoicePlugin accepts connections from game clients who have been supplied the IP and port number to contact by the initial game system login. |
Method Summary | |
---|---|
void |
acceptConnection(ClientConnection con)
The callback from ClientTCPIO invoked when a connection is established. |
void |
addGroup(OID groupOid,
VoiceGroup group)
Inform the VoicePlugin about the existance of a voice group. |
protected void |
addToPerceptionFilter(OID playerOid)
Internal method that adds the playerOid to the list of oids for which the perception filter will send perception messages. |
void |
connectionReset(ClientConnection con)
In response to a ClientConnection being closed, deallocate all voices in use by the connection, and remove the listeners, and close record stream if it's open. |
static int |
encodedFrameSizeForMode(int mode,
boolean wideBand)
Return the total frame size for narrow or wide-band mode given |
static int |
encodedFrameSizeFromFirstByte(byte b)
Return the frame size for the band/mode specified by the first byte of the Speex frame. |
protected void |
expungeVoiceClient(OID playerOid)
Remove the voice client associated with the playerOid from the VoicePlugin data structures. |
protected void |
expungeVoiceClient(OID playerOid,
VoiceConnection con)
Remove the voice client associated with the playerOid from the VoicePlugin data structures. |
protected VoiceGroup |
findVoiceGroup(OID groupOid)
Return the group for groupOid, having checked to see that the group exists and contains the player. |
java.lang.String |
formatCon(ClientConnection con)
Produce a string description of the ClientConnection object. |
VoiceConnection |
getConnectionData(ClientConnection con)
Get the VoiceConnection object associated with the ClientConnection. |
static VoicePlugin |
getInstance()
|
protected GroupMember |
getPlayerMember(OID playerOid)
Get the GroupMember associated with the playerOid, or null if there is none. |
static short |
incSeqNum(short original)
Increment the short seqNum so that it wraps around properly. |
static short |
incSeqNum(short original,
int byWhat)
Increment the short seqNum so that it wraps around properly. |
protected void |
initializeIgnoreList(VoiceConnection playerCon)
|
void |
onActivate()
Register the hooks and create the subscriptions for the VoicePlugin. |
static java.lang.String |
opcodeString(byte opcode)
Return a string representation of the opcode number; used for logging. |
protected java.io.BufferedOutputStream |
openSpeexVoiceFile(OID oid)
Internal method used when writing Speex voice files. |
void |
processAuthenticationPacket(VoiceConnection playerCon,
AOByteBuffer buf)
Check to see of the auth packet contains the proper credentials, and if so, create a group member in the specified group. |
protected void |
processIgnoreListChangeMessage(VoiceConnection playerCon,
AOByteBuffer buf)
Change the ignored status of a set of potential speakers. |
void |
processPacket(ClientConnection con,
AOByteBuffer buf)
Process a packet received from a player. |
protected void |
removeFromPerceptionFilter(OID playerOid)
Internal method that removes the playerOid from the list of oids for which the perception filter will send perception messages. |
void |
removeGroup(OID groupOid)
Remove a group. |
void |
removePlayerFromGroup(VoiceConnection playerCon)
Remove the player identified by the argument from the group it belongs to. |
void |
sendAllocateVoice(VoiceConnection speaker,
VoiceConnection listener,
byte voiceNumber,
boolean positional)
Send an allocate voice packet to the listener, representing a voice channel from the speaker to the listener. |
void |
sendAllocateVoice(VoiceConnection speaker,
VoiceConnection listener,
byte voiceNumber,
byte opcode)
Send an allocate voice packet to the listener, representing a voice channel from the speaker to the listener. |
void |
sendDeallocateVoice(VoiceConnection speaker,
VoiceConnection listener,
byte voiceNumber)
Send a message to the connection deallocating the voice with the given number. |
void |
sendExtensionMessage(WorldManagerClient.ExtensionMessage msg)
Send an ExtensionMessage. |
void |
sendLoginStatus(VoiceConnection receiver,
OID playerOid,
boolean login)
Send a login status message, telling the receiver that a player has logged in. |
protected void |
sendLoginStatusToReceivers(OID playerOid,
boolean login)
Used only when running voice bots. |
void |
sendVoiceFrame(VoiceConnection speaker,
VoiceConnection listener,
byte opcode,
byte voiceNumber,
AOByteBuffer sourceBuf,
short pktLength)
Send a message containing voice frame(s) to the listener. |
protected void |
trackNewPerceiver(PositionalGroupMember member)
Internal method to add the positional group member to the set of member whose perceived players will be tracked. |
protected void |
writeSpeexData(java.io.BufferedOutputStream recordSpeexStream,
byte[] buf,
int startIndex,
int byteCount)
Write a single Speex frame to the stream, from the byte array |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte voicePacketHeaderSize
public static final byte opcodeVoiceUnallocated
public static final byte opcodeAuthenticate
public static final byte opcodeAllocateCodec
public static final byte opcodeAllocatePositionalCodec
public static final byte opcodeReconfirmCodec
public static final byte opcodeDeallocate
public static final byte opcodeData
public static final byte opcodeAggregatedData
public static final byte opcodeLoginStatus
public static final byte opcodeChangeIgnoredStatus
public static final int opcodeHighest
public static java.lang.String[] opcodeNames
public static int[] voiceMsgSize
public static int lengthBytes
public static int[] speexNarrowBandFrameSize
public static int[] speexWideBandFrameSize
public static int maxVoiceChannels
public static CountLogger.Counter countSendLoginStatus
public static CountLogger.Counter countAllocateVoiceReceived
public static CountLogger.Counter countDeallocateVoiceReceived
public static CountLogger.Counter countAllocateVoiceSent
public static CountLogger.Counter countDeallocateVoiceSent
public static boolean runHistograms
public static TimeHistogram processPacketHistogram
public static TimeHistogram dataSendHistogram
public static TimeHistogram voiceAllocHistogram
public static TimeHistogram voiceDeallocHistogram
public static boolean checkAuthToken
protected static boolean createGroupWhenReferenced
protected static boolean allowVoiceBots
protected static float hystericalMargin
protected static VoicePlugin instance
protected PerceptionFilter perceptionFilter
protected long perceptionSubId
protected atavism.server.plugins.VoicePlugin.Updater updater
protected java.lang.Thread updaterThread
protected boolean running
protected transient java.util.concurrent.locks.Lock lock
Constructor Detail |
---|
public VoicePlugin()
Method Detail |
---|
public static VoicePlugin getInstance()
public void onActivate()
onActivate
in class EnginePlugin
public void acceptConnection(ClientConnection con)
acceptConnection
in interface ClientConnection.AcceptCallback
con
- The ClientConnection object for the new connection.protected void sendLoginStatusToReceivers(OID playerOid, boolean login)
protected GroupMember getPlayerMember(OID playerOid)
playerOid
- The oid of the member returned.
public void processPacket(ClientConnection con, AOByteBuffer buf)
processPacket
in interface ClientConnection.MessageCallback
con
- The VoiceConnection object of the player sending the
packet.buf
- The buffer containing the packet. The buf limit is
the size of the packet.protected void writeSpeexData(java.io.BufferedOutputStream recordSpeexStream, byte[] buf, int startIndex, int byteCount)
recordSpeexStream
- The stream to which the voice frame(s) should be written.buf
- The buffer containing the voice frame(s).startIndex
- The index in the buf of the first byte to be written.byteCount
- The number of bytes of frame data to be written.public void processAuthenticationPacket(VoiceConnection playerCon, AOByteBuffer buf)
playerCon
- The VoiceConnection object for the player that
sent the auth packet.buf
- The buffer containing the auth packet.protected void initializeIgnoreList(VoiceConnection playerCon)
protected void trackNewPerceiver(PositionalGroupMember member)
member
- The positional group member to be tracked.protected void processIgnoreListChangeMessage(VoiceConnection playerCon, AOByteBuffer buf)
playerCon
- The VoiceConnection object for the player that
sent the blacklist packet.buf
- The buffer containing the blacklist message.protected void addToPerceptionFilter(OID playerOid)
playerOid
- The oid of the player to be added to the
perception filter.protected void removeFromPerceptionFilter(OID playerOid)
playerOid
- The oid of the player to be removed to the
perception filter.public void removePlayerFromGroup(VoiceConnection playerCon)
playerCon
- The VoiceConnection object corresponding to the player.protected VoiceGroup findVoiceGroup(OID groupOid)
groupOid
- The oid of the group to be returned.public void addGroup(OID groupOid, VoiceGroup group)
groupOid
- The oid of the voice group to be added.group
- The voice group to be added.public void removeGroup(OID groupOid)
groupOid
- The oid of the voice group to be removed.public void sendAllocateVoice(VoiceConnection speaker, VoiceConnection listener, byte voiceNumber, boolean positional)
sendAllocateVoice
in interface VoiceSender
speaker
- The VoiceConnection object for the speaker.listener
- The VoiceConnection object for the listener.voiceNumber
- The listener-specific number of the voice
channel that is created by this allocation.positional
- If true, this voice channel is positional; if
false, non-positional.public void sendAllocateVoice(VoiceConnection speaker, VoiceConnection listener, byte voiceNumber, byte opcode)
sendAllocateVoice
in interface VoiceSender
speaker
- The VoiceConnection object for the speaker.listener
- The VoiceConnection object for the listener.voiceNumber
- The listener-specific number of the voice
channel that is created by this allocation.opcode
- The allocate opcode of the packet to be sent;
there are three kinds of allocate packets, each with different
opcodes, but at this time, only opcodeAllocateCodec is ever
sent.public void sendDeallocateVoice(VoiceConnection speaker, VoiceConnection listener, byte voiceNumber)
sendDeallocateVoice
in interface VoiceSender
speaker
- The VoiceConnection object for the speaker.listener
- The VoiceConnection object for the listener.voiceNumber
- The listener-specific number of the voice
channel that is removed by this deallocation.public void sendVoiceFrame(VoiceConnection speaker, VoiceConnection listener, byte opcode, byte voiceNumber, AOByteBuffer sourceBuf, short pktLength)
sendVoiceFrame
in interface VoiceSender
speaker
- The VoiceConnection object for the speaker.listener
- The VoiceConnection object for the listener.opcode
- The opcode of the voice frame(s) packet. There
are two possible opcodes: opcodeData, which sends a single
frame, and opcodeAggregatedData, which sends multiple voice
frames.voiceNumber
- The listener-specific number of the voice
channel that is removed by this deallocation.sourceBuf
- The buffer containing the voice frame(s).pktLength
- The number of bytes in the buffer.public void sendLoginStatus(VoiceConnection receiver, OID playerOid, boolean login)
receiver
- The VoiceConnection object for the voice bot
manager to receive the packet.playerOid
- The oid of the player whose login status
changed.login
- If true, the playerOid logged in; if false, the
playerOid logged out.public void sendExtensionMessage(WorldManagerClient.ExtensionMessage msg)
sendExtensionMessage
in interface VoiceSender
msg
- The ExtensionMessage to be sent.protected java.io.BufferedOutputStream openSpeexVoiceFile(OID oid)
oid
- The oid used to look up the voice file.
public VoiceConnection getConnectionData(ClientConnection con)
con
- The ClientConnection object whose VoiceConnection should be returned.
public java.lang.String formatCon(ClientConnection con)
con
- The ClientConnection object whose description is to be returned.
public void connectionReset(ClientConnection con)
connectionReset
in interface ClientConnection.MessageCallback
con
- The ClientConnection object that was closed.protected void expungeVoiceClient(OID playerOid)
playerOid
- The oid of the player being expunged.protected void expungeVoiceClient(OID playerOid, VoiceConnection con)
playerOid
- The oid of the player being expunged.con
- The VoiceConnection object for the player.public static short incSeqNum(short original)
original
- The seqNum before being incremented.
public static short incSeqNum(short original, int byWhat)
original
- The seqNum before being incremented.byWhat
- The amount to increment the seqNum by.
public static int encodedFrameSizeForMode(int mode, boolean wideBand)
mode
- The Speex mode number for the frame.wideBand
- If true, the frame is wide-band; if false,
narrow-band.
public static int encodedFrameSizeFromFirstByte(byte b)
b
- The first byte of the Speex frame.
public static java.lang.String opcodeString(byte opcode)
opcode
- The voice packet opcode.
|
Copyright © 2018 Dragonsan Studios Sp. z o.o. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |