Changeset 7684 for code/branches/masterserver/src/libraries
- Timestamp:
- Dec 1, 2010, 1:51:15 PM (14 years ago)
- Location:
- code/branches/masterserver/src/libraries/network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/masterserver/src/libraries/network/MasterServerComm.cc
r7672 r7684 46 46 return 1; 47 47 } 48 49 /* initialize the event holder */ 50 this->event = (ENetEvent *)calloc( sizeof(ENetEvent), 1 ); 48 51 49 52 /* install atexit handler for enet */ … … 89 92 90 93 /* Wait up to 2 seconds for the connection attempt to succeed. */ 91 if (enet_host_service (this->client, &this->event, 2000) > 0 &&92 this->event .type == ENET_EVENT_TYPE_CONNECT )94 if (enet_host_service (this->client, this->event, 2000) > 0 && 95 this->event->type == ENET_EVENT_TYPE_CONNECT ) 93 96 fprintf( stdout, "Connection to server succeeded." ); 94 97 else … … 107 110 /* see whether anything happened */ 108 111 /* WORK MARK REMOVE THIS OUTPUT */ 109 COUT(2) << "MARK polling...\n";112 //COUT(2) << "MARK polling...\n"; 110 113 111 114 /* enet_host_service returns 0 if no event occured */ 112 115 /* just newly set below test to >0 from >= 0, to be tested */ 113 if( enet_host_service( this->client, &this->event, 1000 ) > 0 )116 if( enet_host_service( this->client, this->event, 1000 ) > 0 ) 114 117 { 115 118 /* address buffer */ … … 118 121 119 122 /* check what type of event it is and react accordingly */ 120 switch (this->event .type)123 switch (this->event->type) 121 124 { /* new connection, not supposed to happen. */ 122 125 case ENET_EVENT_TYPE_CONNECT: break; … … 128 131 case ENET_EVENT_TYPE_RECEIVE: 129 132 addrconv = (char *) calloc( 50, 1 ); 130 enet_address_get_host_ip( &(this->event.peer->address), addrconv, 49 ); 133 enet_address_get_host_ip( &(this->event->peer->address), 134 addrconv, 49 ); 131 135 132 136 /* DEBUG */ 133 137 printf( "A packet of length %u containing %s was " 134 138 "received from %s on channel %u.\n", 135 this->event .packet->dataLength,136 this->event .packet->data,139 this->event->packet->dataLength, 140 this->event->packet->data, 137 141 addrconv, 138 this->event .channelID );142 this->event->channelID ); 139 143 /* END DEBUG */ 140 144 141 145 /* call the supplied callback, if any. */ 142 146 if( (*callback) != NULL ) 143 retval = (*callback)( addrconv, &(this->event) );144 145 enet_packet_destroy( event .packet );147 retval = (*callback)( addrconv, (this->event) ); 148 149 enet_packet_destroy( event->packet ); 146 150 if( addrconv ) free( addrconv ); 147 151 break; -
code/branches/masterserver/src/libraries/network/MasterServerComm.h
r7650 r7684 85 85 86 86 /** event data holder */ 87 ENetEvent event;87 ENetEvent *event; 88 88 89 89 /** address holder */
Note: See TracChangeset
for help on using the changeset viewer.