ソースを参照

merged conflict

Vladyslav Hrytsenko 5 年 前
コミット
7d2e620e97
2 ファイル変更22 行追加8 行削除
  1. 15 8
      README.md
  2. 7 0
      include/enet.h

+ 15 - 8
README.md

@@ -48,8 +48,8 @@ we are trying to change some things, things, which can't be reflected on the mai
 ## Description
 ## Description
 
 
 ENet's purpose is to provide a relatively thin, simple and robust network communication
 ENet's purpose is to provide a relatively thin, simple and robust network communication
-layer on top of UDP (User Datagram Protocol).The primary feature it provides is optional
-reliable, in-order delivery of packets.
+layer on top of UDP (User Datagram Protocol). The primary feature it provides is optional
+reliable, in-order delivery of packets, and fragmentation.
 
 
 ENet omits certain higher level networking features such as authentication, lobbying,
 ENet omits certain higher level networking features such as authentication, lobbying,
 server discovery, encryption, or other similar tasks that are particularly application
 server discovery, encryption, or other similar tasks that are particularly application
@@ -57,7 +57,7 @@ specific so that the library remains flexible, portable, and easily embeddable.
 
 
 ## Installation (via npm)
 ## Installation (via npm)
 
 
-Install library using (omit `--save` if you dont have npm project initilized)
+Install library using (omit `--save` if you don't have npm project initilized)
 
 
 ```sh
 ```sh
 $ npm install enet.c --save
 $ npm install enet.c --save
@@ -128,9 +128,9 @@ int main() {
 
 
 ## Usage (Direct, Preferred)
 ## Usage (Direct, Preferred)
 
 
-In this case library will be built-in inside the project itself.
+In this case, library will be embedded to the project itself.
 
 
-Make sure you add a define for `ENET_IMPLEMENTATION` before including the `enet.h`.
+Make sure you add a define for `ENET_IMPLEMENTATION` exactly in one source file before including the `enet.h`.
 
 
 Here is a simple server demo, it will wait 1 second for events, and then exit if none were found:
 Here is a simple server demo, it will wait 1 second for events, and then exit if none were found:
 
 
@@ -172,24 +172,31 @@ int main() {
                 /* Store any relevant client information here. */
                 /* Store any relevant client information here. */
                 event.peer->data = "Client information";
                 event.peer->data = "Client information";
                 break;
                 break;
+
             case ENET_EVENT_TYPE_RECEIVE:
             case ENET_EVENT_TYPE_RECEIVE:
                 printf("A packet of length %lu containing %s was received from %s on channel %u.\n",
                 printf("A packet of length %lu containing %s was received from %s on channel %u.\n",
                         event.packet->dataLength,
                         event.packet->dataLength,
                         event.packet->data,
                         event.packet->data,
                         event.peer->data,
                         event.peer->data,
                         event.channelID);
                         event.channelID);
-
                 /* Clean up the packet now that we're done using it. */
                 /* Clean up the packet now that we're done using it. */
                 enet_packet_destroy (event.packet);
                 enet_packet_destroy (event.packet);
                 break;
                 break;
 
 
             case ENET_EVENT_TYPE_DISCONNECT:
             case ENET_EVENT_TYPE_DISCONNECT:
-                printf ("%s disconnected.\n", event.peer->data);
+                printf("%s disconnected.\n", event.peer->data);
                 /* Reset the peer's client information. */
                 /* Reset the peer's client information. */
                 event.peer->data = NULL;
                 event.peer->data = NULL;
                 break;
                 break;
 
 
-            case ENET_EVENT_TYPE_NONE: break;
+            case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT:
+                printf("%s disconnected due to timeout.\n", event.peer->data);
+                /* Reset the peer's client information. */
+                event.peer->data = NULL;
+                break;
+
+            case ENET_EVENT_TYPE_NONE:
+                break;
         }
         }
     }
     }
 
 

+ 7 - 0
include/enet.h

@@ -1543,11 +1543,18 @@ extern "C" {
         if (event != NULL) {
         if (event != NULL) {
             enet_protocol_change_state(host, peer, ENET_PEER_STATE_CONNECTED);
             enet_protocol_change_state(host, peer, ENET_PEER_STATE_CONNECTED);
 
 
+<<<<<<< HEAD
             peer->totalDataSent     = 0;
             peer->totalDataSent     = 0;
             peer->totalDataReceived = 0;
             peer->totalDataReceived = 0;
             peer->totalPacketsSent  = 0;
             peer->totalPacketsSent  = 0;
             peer->totalPacketsLost  = 0;
             peer->totalPacketsLost  = 0;
 
 
+=======
+            peer->totalDataSent = 0;
+            peer->totalDataReceived = 0;
+            peer->totalPacketsSent = 0;
+            peer->totalPacketsLost = 0;
+>>>>>>> 49c98669270b83ce4b05785fa917e10cce389e00
             event->type = ENET_EVENT_TYPE_CONNECT;
             event->type = ENET_EVENT_TYPE_CONNECT;
             event->peer = peer;
             event->peer = peer;
             event->data = peer->eventData;
             event->data = peer->eventData;