zenilib: zenilib/jni/external/sdl_net/chat.cpp File Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Enumerations | Functions | Variables
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_Surface * | images [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

enum image_names

Enumerator
IMAGE_QUIT |
IMAGE_SCROLL_UP |
IMAGE_SCROLL_DN |
NUM_IMAGES |

Definition at line 55 of file chat.cpp.

## Function Documentation

void cleanup | ( | int | exitcode | ) |

Definition at line 339 of file chat.cpp.

References gui, i, NULL, NUM_IMAGES, SDL_FreeSurface(), SDL_Quit(), SDLNet_FreePacketV(), SDLNet_FreeSocketSet(), SDLNet_Quit(), SDLNet_TCP_Close(), SDLNet_UDP_Close(), socketset, tcpsock, and udpsock.

Referenced by main().

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 |  | ) |

Definition at line 242 of file chat.cpp.

References HandleServerData(), NULL, SDLNet_TCP_Close(), SDLNet_TCP_DelSocket(), SDLNet_TCP_Recv(), socketset, tcpsock, and termwin.

Referenced by HandleNet(), and main().

int HandleServerData | ( | Uint8 * | data | ) |

Definition at line 167 of file chat.cpp.

References active, CHAT_ADD, CHAT_ADD_HOST, CHAT_ADD_NAME, CHAT_ADD_NLEN, CHAT_ADD_PORT, CHAT_ADD_SLOT, CHAT_BYE, CHAT_BYE_LEN, CHAT_DEL, CHAT_DEL_LEN, CHAT_DEL_SLOT, CHAT_MAXPEOPLE, IPaddress::host, memcpy, people, IPaddress::port, SDL_SwapBE16, SDL_SwapBE32, SDLNet_Read16, SDLNet_Read32, SDLNet_UDP_Bind(), SDLNet_UDP_Unbind(), termwin, and udpsock.

Referenced by HandleServer().

void InitGUI | ( | SDL_Surface * | screen | ) |

Definition at line 302 of file chat.cpp.

References CHAT_PROMPT, CHAT_SCROLLBACK, gui, SDL_Surface::h, IMAGE_QUIT, IMAGE_SCROLL_DN, IMAGE_SCROLL_UP, NULL, SendKey(), sendwin, termwin, and SDL_Surface::w.

Referenced by main().

int main | ( | int | argc,
|  | char * | argv[]
| ) |  |

Definition at line 377 of file chat.cpp.

References CHAT_PACKETSIZE, CHAT_PORT, cleanup(), gui, HandleNet(), IPaddress::host, i, image_files, INADDR_NONE, InitGUI(), NULL, NUM_IMAGES, SDL_GetError(), SDL_Init(), SDL_INIT_VIDEO, SDL_LoadBMP, SDL_Quit(), SDL_SWSURFACE, SDLNet_AllocPacketV(), SDLNet_AllocSocketSet(), SDLNet_GetError(), SDLNet_Init(), SDLNet_ResolveHost(), SDLNet_TCP_AddSocket(), SDLNet_TCP_Close(), SDLNet_TCP_Open(), SDLNet_UDP_AddSocket(), SDLNet_UDP_Open(), SendHello(), socketset, tcpsock, termwin, and udpsock.

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 SendHello | ( | char * | name | ) |

Definition at line 67 of file chat.cpp.

References CHAT_HELLO, CHAT_HELLO_NAME, CHAT_HELLO_NLEN, CHAT_HELLO_PORT, CHAT_MAXPEOPLE, hello, i, memcpy, NULL, people, IPaddress::port, SDLNet_TCP_Send(), SDLNet_UDP_GetPeerAddress(), tcpsock, termwin, and udpsock.

Referenced by main().

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().

SDL_Surface* images[NUM_IMAGES]

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]

Referenced by HandleClient(), HandleServerData(), SendBuf(), and SendHello().

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().