C# Класс AnimatorServer.AnimationServer

Communicates with clients to upload and start playing animations
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
ConnectToSerial void
DisconnectFromSerial void
ListenForClients void
Play void
ProcessClient void
ProcessDeleteAnimationCommand void
ProcessGetStatusCommand void
ProcessGetTitlesCommand void
ProcessGetUploadedAnimationsCommand void
ProcessPlayCommand void
ProcessStopCommand void
ProcessUploadAnimationCommand void
SendFrameToSerial void
StartListening void

Открытые методы

Метод Описание
AnimationServer ( ) : System

Initializes a new instance of the AnimationServer class. Sets the status to Idle.

GetAnimationTitles ( ) : List

Returns a list of animation titles.

Приватные методы

Метод Описание
ConnectToSerial ( ) : void

Try to initialize the serial communications.

DisconnectFromSerial ( ) : void

Disconnect from serial and free up the com port.

ListenForClients ( ) : void

This function is designed to be run in a seperator thread. It listens for a new client, accepts the client and processes it, checks if the the server is still in listening mode, and then either exits or waits for another client.

Play ( ) : void

Plays the selected animation. Designed to be run in a seperate thread.

ProcessClient ( TcpClient tcpClient ) : void

Process the data from a client

ProcessDeleteAnimationCommand ( NetworkStream clientStream ) : void

Process a delete command. Gets 4 bytes that represent the animation index integer and deletes the corresponding animation in the list.

ProcessGetStatusCommand ( NetworkStream clientStream ) : void

Process a get status command.

ProcessGetTitlesCommand ( NetworkStream clientStream ) : void

Process a list command.

ProcessGetUploadedAnimationsCommand ( NetworkStream clientStream ) : void

Process a get uploaded animations command. It deseralizes a list of md5 hashes sent over the stream, and then only sends the animations that don't have hashes listed.

ProcessPlayCommand ( NetworkStream clientStream ) : void

Process a play command. Starts a new thread and plays the animation.

ProcessStopCommand ( NetworkStream clientStream ) : void

Process a stop command. Sets a flags that stops the animation playing thread and optionally sends a blank frame out.

ProcessUploadAnimationCommand ( NetworkStream clientStream ) : void

Process an upload command from a client. Deserializes the Animation send over the stream and adds it to the list of animations. TODO: Throw exceptions when this function is called and the server is in the wrong state.

SendFrameToSerial ( KeyFrame currentFrame ) : void

Send a keyframe to the microcontroller using the packet protocol

StartListening ( ) : void

Spawns a thread that listens for new connections. It executes any commands and then exits the thread. If the Server is already listening, then the method does nothing.

Описание методов

AnimationServer() публичный Метод

Initializes a new instance of the AnimationServer class. Sets the status to Idle.
public AnimationServer ( ) : System
Результат System

GetAnimationTitles() публичный Метод

Returns a list of animation titles.
public GetAnimationTitles ( ) : List
Результат List