![]() |
home | contact us | about us | |
| (by Lou Burne, last updated 10-APRIL-2012) | ||
| Tinychat.cs | The
application
functions. The main application function is described
below. |
| TinychatHelper.cs | A concrete
class that will convert a chatroom name into a set of RTMP
parameters. Tinychat has a rather odd way of encoding strings, so TinychatHelper also has two functions for converting a string to and from the Tinychat string format. |
| WebsiteRequestHelper.cs | A static class for loading a webpage as a string or an XML document. |
| A | Construct a
TinychatHelper object. The TinychatHelper constructor
takes a chatroom name and populated the object with a set of RTMP parameters. |
| B | Create a new RtmpClient object. The RtmpClient constructor takes one parameter, a reference to the main
application window. Since our application runs in a console, which is windowless, this parameter can be null. EventsEnabled - Set EventsEnabled to false so the RtmpClient doesn't waste time composing events when no one is listening. |
| C | Create a new Rtmp
connection. The RtmpConnection object returned encapsulates a connection to
the remote RTMP server. The behavior flags instruct the RtmpClient library to automatically respond to any request for pings or data acknowledgements that come from the server. |
| D | Register for
automatic mounting of new streams. When the connection to Tinychat is opened the stream with id of zero, "stream0", is automatically opened. We need to do things with this stream, but we can't open it again to get a reference to it. Instead, we instruct the RtmpClient that any new streams opened by the server should be wrapped as a RtmpStream object as if we had opened the stream ourselves. The function RegisterAutomaticStreamMountingCallback is where we set up the callback function for automatic mounting. Instead of defining a separate callback function we are using an anonymous function (=>). If you are not familiar with anonymous functions, this will look a bit peculiar, but they are worth getting used to as they allow for more compact code, and negate having to worry about getting object references into a static callback function. |
| E | Register for
pre-processing of all RTMP messages arriving on stream0. These RTMP messages will include chatroom text messages and details of who is entering or leaving the chatroom. We use this callback to pass these messages to our function _fnStream0Callback. More details about this function below. |
| F | Connect to the
RTMP application. Tinychat uses a few more parameters than the standard RTMP connection, so we have created a standard connection message, and then customized it by adding extra parameters to it. |
| G | All that remains
is to take commands through the console from the user. In the loop, the user can enter "exit" to close the application, otherwise whatever they enter is transmitted to the chatroom. |
| A | The chatroom messages we are interested in are of type CommandAmf0. |
| B | Chatroom messages
start with a verb, for example, "joins" for details of who is in
the chatroom, and "privmsg" for a text message. |
| C | Verb "privmsg"
indicates a text message, either sent by another guest in the
chatroom, or sent by us to the chatroom. The textual component of this message is encoded into comma delimited ASCII. There are two functions in the TinychatHelper.cs file to encode and encode these strings. |
| D | Verb "notice"
indicates a message contained a textual message that can be
printed straight to the console. |
![]() |
© 1998-2012 Broccoli Products Ltd Reg Number: 2895355 Reg Office: 27 Old Gloucester Street, London. WC1N 3AX |
Privacy Policy Copyright Notice Liability Disclaimer Contact Us |
|