zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
chat.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL_net.h"
#include <GUI/GUI.h>
#include <GUI/GUI_widgets.h>
#include "chat.h"

Go to the source code of this file.

Enumerations

enum  image_names { IMAGE_QUIT, IMAGE_SCROLL_UP, IMAGE_SCROLL_DN, NUM_IMAGES }
 

Functions

void cleanup (int exitcode)
 
void HandleClient (void)
 
GUI_status HandleNet (void)
 
void HandleServer (void)
 
int HandleServerData (Uint8 *data)
 
void InitGUI (SDL_Surface *screen)
 
int main (int argc, char *argv[])
 
void SendBuf (char *buf, int len)
 
void SendHello (char *name)
 
void SendKey (SDLKey key, Uint16 unicode)
 

Variables

static GUI * gui = NULL
 
char * image_files [NUM_IMAGES]
 
SDL_Surfaceimages [NUM_IMAGES]
 
static UDPpacket ** packets = NULL
 
struct {
   int   active
 
   Uint8   name [256+1]
 
people [CHAT_MAXPEOPLE]
 
static GUI_TermWin * sendwin
 
static SDLNet_SocketSet socketset = NULL
 
static TCPsocket tcpsock = NULL
 
static GUI_TermWin * termwin
 
static UDPsocket udpsock = NULL
 

Enumeration Type Documentation

Enumerator
IMAGE_QUIT 
IMAGE_SCROLL_UP 
IMAGE_SCROLL_DN 
NUM_IMAGES 

Definition at line 55 of file chat.cpp.

Function Documentation

void HandleClient ( void  )

Definition at line 270 of file chat.cpp.

References people, SDLNet_UDP_RecvV(), termwin, and udpsock.

Referenced by HandleNet(), and main().

GUI_status HandleNet ( void  )

Definition at line 284 of file chat.cpp.

References HandleClient(), HandleServer(), SDLNet_CheckSockets(), SDLNet_SocketReady, socketset, tcpsock, termwin, and udpsock.

Referenced by main().

void HandleServer ( void  )
void InitGUI ( SDL_Surface screen)
void SendBuf ( char *  buf,
int  len 
)

Definition at line 104 of file chat.cpp.

References active, CHAT_MAXPEOPLE, CHAT_PROMPT, i, UDPpacket::len, UDPpacket::maxlen, memcpy, people, SDLNet_UDP_Send(), sendwin, and udpsock.

Referenced by SendKey().

void SendKey ( SDLKey  key,
Uint16  unicode 
)

Definition at line 125 of file chat.cpp.

References CHAT_PROMPT, SendBuf(), and sendwin.

Referenced by InitGUI().

Variable Documentation

int active

Definition at line 48 of file chat.cpp.

GUI* gui = NULL
static

Definition at line 52 of file chat.cpp.

Referenced by cleanup(), InitGUI(), main(), and Zeni::Game::run().

char* image_files[NUM_IMAGES]
Initial value:
= {
"quit.bmp", "scroll_up.bmp", "scroll_dn.bmp"
}

Definition at line 61 of file chat.cpp.

Referenced by main().

Definition at line 64 of file chat.cpp.

Uint8 name[256+1]

Definition at line 49 of file chat.cpp.

UDPpacket** packets = NULL
static

Definition at line 46 of file chat.cpp.

Referenced by SDLNet_UDP_Recv().

struct { ... } people[CHAT_MAXPEOPLE]
GUI_TermWin* sendwin
static

Definition at line 54 of file chat.cpp.

Referenced by InitGUI(), SendBuf(), and SendKey().

SDLNet_SocketSet socketset = NULL
static

Definition at line 45 of file chat.cpp.

Referenced by cleanup(), HandleNet(), HandleServer(), and main().

TCPsocket tcpsock = NULL
static

Definition at line 43 of file chat.cpp.

Referenced by cleanup(), HandleNet(), HandleServer(), main(), and SendHello().

GUI_TermWin* termwin
static

Definition at line 53 of file chat.cpp.

Referenced by HandleClient(), HandleNet(), HandleServer(), HandleServerData(), InitGUI(), main(), and SendHello().

UDPsocket udpsock = NULL
static

Definition at line 44 of file chat.cpp.

Referenced by cleanup(), HandleClient(), HandleNet(), HandleServerData(), main(), SendBuf(), and SendHello().