Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы / 2 / lab.03.by mice / claw / server
.h/*******************************************************************************
* file: server.h *
* version: 0.0.3 *
* author: d-evil [tmd] (mailto:d-evil.tmd@mail.ru) *
* description: not available *
*******************************************************************************/
#ifndef SERVER_INCLUDED
#define SERVER_INCLUDED
#include <afx.h>
#include <afxwin.h>
#include "resource.h"
#include "fake_socket.h"
#include "win_errors.h"
#include "client.h"
////////////////////////////////////////////////////////////////////////////////
// ccw_server declaration
class ccw_server: public CDialog {
public:
////////////////////////////////////////////////////////////////////////////
// ccw_server public constants
static const int MSG_ADD_RECVER = WM_USER + 0xCD;
// WPARAM: (ccw_client **)client_added
// LPARAM: not used
static const int MSG_DEL_RECVER = WM_USER + 0xDD;
// WPARAM: (int)claw_id
// LPARAM: not used
static const int MSG_DEL_SERVER = WM_USER + 0xDA;
// WPARAM: (int)claw_id
// LPARAM: not used
ccw_server();
~ccw_server();
HICON get_icon() const { return _hicon; }
void set_icon(const HICON hicon) { _hicon = hicon; }
CWnd * get_parent() const { return _parent; }
void set_parent(CWnd *const parent) { _parent = parent; }
int get_claw_id() const { return _claw_id; }
void set_claw_id(const int claw_id) {_claw_id = claw_id; }
int set_caption();
int give_life();
int take_life();
virtual BOOL OnInitDialog();
virtual void OnOK() {}
virtual void OnCancel() {}
virtual void OnClose();
int run();
int stop();
int pause();
int upause();
int wait(const int timeout = 0);
protected:
////////////////////////////////////////////////////////////////////////////
// controls
CEdit *_edit_host;
CEdit *_edit_ip;
CEdit *_edit_port;
CEdit *_edit_status;
CEdit *_edit_time;
CButton *_btn_run;
CButton *_btn_pause;
CButton *_btn_exit;
////////////////////////////////////////////////////////////////////////////
// protected event handlers
DECLARE_MESSAGE_MAP();
void _on_btn_run();
void _on_btn_pause();
void _on_btn_exit();
void _init_controls();
void _lock_edits();
void _ulock_edits();
void _set_rbtn_state(const int st);
void _set_pbtn_state(const int st);
// net
int _serv_proc();
static int _serv_proc_helper(ccw_server *const serv) {
return serv->_serv_proc();
}
private:
CWnd *_parent;
HICON _hicon;
HANDLE _run_mtx;
HANDLE _pause_mtx;
HANDLE _thread_h;
DWORD _thread_id;
bool _stoped;
bool _paused;
int _run_btn_state;
int _pause_btn_state;
CSocket _sock;
int _claw_id;
};
#endif