00001 /* 00002 * ExNihilo 3D Engine 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 * Please read AUTHORS file !!! 00019 * 00020 * $Id: ExManagerNetwork.cpp,v 1.3 2002/11/24 11:58:58 data Exp $ 00021 * 00022 */ 00023 00024 #include "ExManagerNetwork.h" 00025 00026 bool ExManagerNetwork::m_flag = false; 00027 ExManagerNetwork* ExManagerNetwork::m_instance = NULL; 00028 00029 ExManagerNetwork* ExManagerNetwork::CreateSingleton(void){ 00030 Guard(ExManagerNetwork* ExManagerNetwork::CreateSingleton(void)) 00031 if(!m_flag) 00032 { 00033 m_flag = true; // We are creating the error log now, so set flag to true 00034 m_instance = new ExManagerNetwork; // Create the error log 00035 }else 00036 { 00037 std::cout<<"Error singleton already created"<<std::endl; 00038 } 00039 return m_instance; 00040 UnGuard 00041 } 00042 00043 ExManagerNetwork::ExManagerNetwork(void) 00044 { 00045 m_ShowNetStat=false; 00046 } 00047 00048 ExManagerNetwork::~ExManagerNetwork(void) 00049 { 00050 } 00051 00052 void ExManagerNetwork::Init(void) 00053 { 00054 /*m_SocketClient = new ExCSocketClient; 00055 m_SocketClient->SetSocketPort(5000); 00056 m_SocketClient->Init("ploksoftware"); 00057 m_SocketClient->Connect();*/ 00058 /* WSADATA WSAData; 00059 WSAStartup(MAKEWORD(2,0), &WSAData); 00060 00061 SOCKET sock; 00062 SOCKADDR_IN sin; 00063 char *buffer = new char[255]; 00064 00065 sock = socket(AF_INET, SOCK_STREAM, 0); 00066 00067 sin.sin_addr.s_addr = inet_addr("192.168.0.1"); 00068 sin.sin_family = AF_INET; 00069 sin.sin_port = htons(5000); 00070 00071 connect(sock, (SOCKADDR *)&sin, sizeof(sin)); 00072 //recv(sock, buffer, sizeof(buffer), 0); 00073 closesocket(sock); 00074 WSACleanup(); 00075 */ 00076 } 00077 00078 void ExManagerNetwork::Draw(void) 00079 { 00080 if(m_ShowNetStat) 00081 { 00082 glDisable(GL_LIGHTING); 00083 ExNihilo::EnterOrthoMode(); 00084 ExNihilo::RenderBitmapString(30,glutGet(GLUT_WINDOW_HEIGHT)-100,(void *)GLUT_BITMAP_HELVETICA_12,"NetStat"); 00085 ExNihilo::RenderBitmapString(30,glutGet(GLUT_WINDOW_HEIGHT)-80,(void *)GLUT_BITMAP_HELVETICA_12,"Ping : No Connexion"); 00086 ExNihilo::LeaveOrthoMode(); 00087 glEnable(GL_LIGHTING); 00088 } 00089 } 00090 00091 00092 00093 void ExManagerNetwork::Reset(void) 00094 { 00095 Guard(void ExManagerNetwork::Reset(void)) 00096 UnGuard 00097 } 00098 00099 00100 void ExManagerNetwork::Connect(void) 00101 { 00102 Guard(void ExManagerNetwork::Connect(void)) 00103 00104 UnGuard 00105 } 00106 00107 ExCAction ExManagerNetwork::InputAction(ExCAction Action) 00108 { 00109 Guard(ExCAction ExManagerNetwork::InputAction(ExCAction Action)) 00110 switch(Action.m_Action) 00111 { 00112 case SHOW_NET_STAT: 00113 SetNetstatState(true); 00114 break; 00115 case HIDE_NET_STAT: 00116 SetNetstatState(false); 00117 break; 00118 case CONNECT: 00119 Connect(); 00120 break; 00121 } 00122 if(Action.m_NextAction){return *Action.m_NextAction;} 00123 else{return NOTHING;} 00124 UnGuard 00125 }