Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
cf7bd1a7
Unverified
Commit
cf7bd1a7
authored
Dec 16, 2017
by
Rémi Verschelde
Committed by
GitHub
Dec 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14708 from Faless/get_packet_not_const_rebased
Remove "const" from PacketPeer get_packet/get_var, move windows network related stuff to drivers
parents
0a724b81
ac744402
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
90 additions
and
80 deletions
+90
-80
packet_peer.cpp
core/io/packet_peer.cpp
+5
-5
packet_peer.h
core/io/packet_peer.h
+6
-6
packet_peer_udp_posix.cpp
drivers/unix/packet_peer_udp_posix.cpp
+1
-1
packet_peer_udp_posix.h
drivers/unix/packet_peer_udp_posix.h
+6
-6
packet_peer_udp_winsock.cpp
drivers/windows/packet_peer_udp_winsock.cpp
+5
-1
packet_peer_udp_winsock.h
drivers/windows/packet_peer_udp_winsock.h
+10
-6
stream_peer_tcp_winsock.cpp
drivers/windows/stream_peer_tcp_winsock.cpp
+26
-26
stream_peer_tcp_winsock.h
drivers/windows/stream_peer_tcp_winsock.h
+6
-6
tcp_server_winsock.cpp
drivers/windows/tcp_server_winsock.cpp
+6
-2
tcp_server_winsock.h
drivers/windows/tcp_server_winsock.h
+4
-0
networked_multiplayer_enet.cpp
modules/enet/networked_multiplayer_enet.cpp
+2
-2
networked_multiplayer_enet.h
modules/enet/networked_multiplayer_enet.h
+4
-4
SCsub
platform/uwp/SCsub
+0
-3
os_uwp.cpp
platform/uwp/os_uwp.cpp
+4
-4
SCsub
platform/windows/SCsub
+0
-3
os_windows.cpp
platform/windows/os_windows.cpp
+5
-5
No files found.
core/io/packet_peer.cpp
View file @
cf7bd1a7
...
...
@@ -49,7 +49,7 @@ bool PacketPeer::is_object_decoding_allowed() const {
return
allow_object_decoding
;
}
Error
PacketPeer
::
get_packet_buffer
(
PoolVector
<
uint8_t
>
&
r_buffer
)
const
{
Error
PacketPeer
::
get_packet_buffer
(
PoolVector
<
uint8_t
>
&
r_buffer
)
{
const
uint8_t
*
buffer
;
int
buffer_size
;
...
...
@@ -78,7 +78,7 @@ Error PacketPeer::put_packet_buffer(const PoolVector<uint8_t> &p_buffer) {
return
put_packet
(
&
r
[
0
],
len
);
}
Error
PacketPeer
::
get_var
(
Variant
&
r_variant
)
const
{
Error
PacketPeer
::
get_var
(
Variant
&
r_variant
)
{
const
uint8_t
*
buffer
;
int
buffer_size
;
...
...
@@ -107,7 +107,7 @@ Error PacketPeer::put_var(const Variant &p_packet) {
return
put_packet
(
buf
,
len
);
}
Variant
PacketPeer
::
_bnd_get_var
()
const
{
Variant
PacketPeer
::
_bnd_get_var
()
{
Variant
var
;
get_var
(
var
);
...
...
@@ -117,7 +117,7 @@ Variant PacketPeer::_bnd_get_var() const {
Error
PacketPeer
::
_put_packet
(
const
PoolVector
<
uint8_t
>
&
p_buffer
)
{
return
put_packet_buffer
(
p_buffer
);
}
PoolVector
<
uint8_t
>
PacketPeer
::
_get_packet
()
const
{
PoolVector
<
uint8_t
>
PacketPeer
::
_get_packet
()
{
PoolVector
<
uint8_t
>
raw
;
last_get_error
=
get_packet_buffer
(
raw
);
...
...
@@ -202,7 +202,7 @@ int PacketPeerStream::get_available_packet_count() const {
return
count
;
}
Error
PacketPeerStream
::
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
const
{
Error
PacketPeerStream
::
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
{
ERR_FAIL_COND_V
(
peer
.
is_null
(),
ERR_UNCONFIGURED
);
_poll_buffer
();
...
...
core/io/packet_peer.h
View file @
cf7bd1a7
...
...
@@ -37,13 +37,13 @@ class PacketPeer : public Reference {
GDCLASS
(
PacketPeer
,
Reference
);
Variant
_bnd_get_var
()
const
;
Variant
_bnd_get_var
();
void
_bnd_put_var
(
const
Variant
&
p_var
);
static
void
_bind_methods
();
Error
_put_packet
(
const
PoolVector
<
uint8_t
>
&
p_buffer
);
PoolVector
<
uint8_t
>
_get_packet
()
const
;
PoolVector
<
uint8_t
>
_get_packet
();
Error
_get_packet_error
()
const
;
mutable
Error
last_get_error
;
...
...
@@ -52,17 +52,17 @@ class PacketPeer : public Reference {
public
:
virtual
int
get_available_packet_count
()
const
=
0
;
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
const
=
0
;
///< buffer is GONE after next get_packet
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
=
0
;
///< buffer is GONE after next get_packet
virtual
Error
put_packet
(
const
uint8_t
*
p_buffer
,
int
p_buffer_size
)
=
0
;
virtual
int
get_max_packet_size
()
const
=
0
;
/* helpers / binders */
virtual
Error
get_packet_buffer
(
PoolVector
<
uint8_t
>
&
r_buffer
)
const
;
virtual
Error
get_packet_buffer
(
PoolVector
<
uint8_t
>
&
r_buffer
);
virtual
Error
put_packet_buffer
(
const
PoolVector
<
uint8_t
>
&
p_buffer
);
virtual
Error
get_var
(
Variant
&
r_variant
)
const
;
virtual
Error
get_var
(
Variant
&
r_variant
);
virtual
Error
put_var
(
const
Variant
&
p_packet
);
void
set_allow_object_decoding
(
bool
p_enable
);
...
...
@@ -91,7 +91,7 @@ protected:
public
:
virtual
int
get_available_packet_count
()
const
;
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
const
;
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
);
virtual
Error
put_packet
(
const
uint8_t
*
p_buffer
,
int
p_buffer_size
);
virtual
int
get_max_packet_size
()
const
;
...
...
drivers/unix/packet_peer_udp_posix.cpp
View file @
cf7bd1a7
...
...
@@ -65,7 +65,7 @@ int PacketPeerUDPPosix::get_available_packet_count() const {
return
queue_count
;
}
Error
PacketPeerUDPPosix
::
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
const
{
Error
PacketPeerUDPPosix
::
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
{
Error
err
=
const_cast
<
PacketPeerUDPPosix
*>
(
this
)
->
_poll
(
false
);
if
(
err
!=
OK
)
...
...
drivers/unix/packet_peer_udp_posix.h
View file @
cf7bd1a7
...
...
@@ -41,12 +41,12 @@ class PacketPeerUDPPosix : public PacketPeerUDP {
PACKET_BUFFER_SIZE
=
65536
};
mutable
RingBuffer
<
uint8_t
>
rb
;
RingBuffer
<
uint8_t
>
rb
;
uint8_t
recv_buffer
[
PACKET_BUFFER_SIZE
];
mutable
uint8_t
packet_buffer
[
PACKET_BUFFER_SIZE
];
mutable
IP_Address
packet_ip
;
mutable
int
packet_port
;
mutable
int
queue_count
;
uint8_t
packet_buffer
[
PACKET_BUFFER_SIZE
];
IP_Address
packet_ip
;
int
packet_port
;
int
queue_count
;
int
sockfd
;
bool
sock_blocking
;
IP
::
Type
sock_type
;
...
...
@@ -62,7 +62,7 @@ class PacketPeerUDPPosix : public PacketPeerUDP {
public
:
virtual
int
get_available_packet_count
()
const
;
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
const
;
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
);
virtual
Error
put_packet
(
const
uint8_t
*
p_buffer
,
int
p_buffer_size
);
virtual
int
get_max_packet_size
()
const
;
...
...
platform
/windows/packet_peer_udp_winsock.cpp
→
drivers
/windows/packet_peer_udp_winsock.cpp
View file @
cf7bd1a7
...
...
@@ -27,6 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef WINDOWS_ENABLED
#include "packet_peer_udp_winsock.h"
#include <winsock2.h>
...
...
@@ -43,7 +45,7 @@ int PacketPeerUDPWinsock::get_available_packet_count() const {
return
queue_count
;
}
Error
PacketPeerUDPWinsock
::
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
const
{
Error
PacketPeerUDPWinsock
::
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
{
Error
err
=
const_cast
<
PacketPeerUDPWinsock
*>
(
this
)
->
_poll
(
false
);
if
(
err
!=
OK
)
...
...
@@ -291,3 +293,5 @@ PacketPeerUDPWinsock::~PacketPeerUDPWinsock() {
close
();
}
#endif
platform
/windows/packet_peer_udp_winsock.h
→
drivers
/windows/packet_peer_udp_winsock.h
View file @
cf7bd1a7
...
...
@@ -27,6 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef WINDOWS_ENABLED
#ifndef PACKET_PEER_UDP_WINSOCK_H
#define PACKET_PEER_UDP_WINSOCK_H
...
...
@@ -39,12 +41,12 @@ class PacketPeerUDPWinsock : public PacketPeerUDP {
PACKET_BUFFER_SIZE
=
65536
};
mutable
RingBuffer
<
uint8_t
>
rb
;
RingBuffer
<
uint8_t
>
rb
;
uint8_t
recv_buffer
[
PACKET_BUFFER_SIZE
];
mutable
uint8_t
packet_buffer
[
PACKET_BUFFER_SIZE
];
mutable
IP_Address
packet_ip
;
mutable
int
packet_port
;
mutable
int
queue_count
;
uint8_t
packet_buffer
[
PACKET_BUFFER_SIZE
];
IP_Address
packet_ip
;
int
packet_port
;
int
queue_count
;
int
sockfd
;
bool
sock_blocking
;
IP
::
Type
sock_type
;
...
...
@@ -62,7 +64,7 @@ class PacketPeerUDPWinsock : public PacketPeerUDP {
public
:
virtual
int
get_available_packet_count
()
const
;
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
const
;
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
);
virtual
Error
put_packet
(
const
uint8_t
*
p_buffer
,
int
p_buffer_size
);
virtual
int
get_max_packet_size
()
const
;
...
...
@@ -82,3 +84,5 @@ public:
~
PacketPeerUDPWinsock
();
};
#endif // PACKET_PEER_UDP_WINSOCK_H
#endif
platform/windows/stream_peer
_winsock.cpp
→
drivers/windows/stream_peer_tcp
_winsock.cpp
View file @
cf7bd1a7
/*************************************************************************/
/* stream_peer_
winsock.cpp
*/
/* stream_peer_
tcp_winsock.cpp
*/
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
...
...
@@ -29,7 +29,7 @@
/*************************************************************************/
#ifdef WINDOWS_ENABLED
#include "stream_peer_winsock.h"
#include "stream_peer_
tcp_
winsock.h"
#include <winsock2.h>
#include <ws2tcpip.h>
...
...
@@ -38,14 +38,14 @@
int
winsock_refcount
=
0
;
StreamPeerTCP
*
StreamPeerWinsock
::
_create
()
{
StreamPeerTCP
*
StreamPeer
TCP
Winsock
::
_create
()
{
return
memnew
(
StreamPeerWinsock
);
return
memnew
(
StreamPeer
TCP
Winsock
);
};
void
StreamPeerWinsock
::
make_default
()
{
void
StreamPeer
TCP
Winsock
::
make_default
()
{
StreamPeerTCP
::
_create
=
StreamPeerWinsock
::
_create
;
StreamPeerTCP
::
_create
=
StreamPeer
TCP
Winsock
::
_create
;
if
(
winsock_refcount
==
0
)
{
WSADATA
data
;
...
...
@@ -54,7 +54,7 @@ void StreamPeerWinsock::make_default() {
++
winsock_refcount
;
};
void
StreamPeerWinsock
::
cleanup
()
{
void
StreamPeer
TCP
Winsock
::
cleanup
()
{
--
winsock_refcount
;
if
(
winsock_refcount
==
0
)
{
...
...
@@ -63,7 +63,7 @@ void StreamPeerWinsock::cleanup() {
};
};
Error
StreamPeerWinsock
::
_block
(
int
p_sockfd
,
bool
p_read
,
bool
p_write
)
const
{
Error
StreamPeer
TCP
Winsock
::
_block
(
int
p_sockfd
,
bool
p_read
,
bool
p_write
)
const
{
fd_set
read
,
write
;
FD_ZERO
(
&
read
);
...
...
@@ -78,7 +78,7 @@ Error StreamPeerWinsock::_block(int p_sockfd, bool p_read, bool p_write) const {
return
ret
<
0
?
FAILED
:
OK
;
};
Error
StreamPeerWinsock
::
_poll_connection
()
const
{
Error
StreamPeer
TCP
Winsock
::
_poll_connection
()
const
{
ERR_FAIL_COND_V
(
status
!=
STATUS_CONNECTING
||
sockfd
==
INVALID_SOCKET
,
FAILED
);
...
...
@@ -108,7 +108,7 @@ Error StreamPeerWinsock::_poll_connection() const {
return
OK
;
};
Error
StreamPeerWinsock
::
write
(
const
uint8_t
*
p_data
,
int
p_bytes
,
int
&
r_sent
,
bool
p_block
)
{
Error
StreamPeer
TCP
Winsock
::
write
(
const
uint8_t
*
p_data
,
int
p_bytes
,
int
&
r_sent
,
bool
p_block
)
{
if
(
status
==
STATUS_NONE
||
status
==
STATUS_ERROR
)
{
...
...
@@ -166,7 +166,7 @@ Error StreamPeerWinsock::write(const uint8_t *p_data, int p_bytes, int &r_sent,
return
OK
;
};
Error
StreamPeerWinsock
::
read
(
uint8_t
*
p_buffer
,
int
p_bytes
,
int
&
r_received
,
bool
p_block
)
{
Error
StreamPeer
TCP
Winsock
::
read
(
uint8_t
*
p_buffer
,
int
p_bytes
,
int
&
r_received
,
bool
p_block
)
{
if
(
!
is_connected_to_host
())
{
...
...
@@ -224,29 +224,29 @@ Error StreamPeerWinsock::read(uint8_t *p_buffer, int p_bytes, int &r_received, b
return
OK
;
};
Error
StreamPeerWinsock
::
put_data
(
const
uint8_t
*
p_data
,
int
p_bytes
)
{
Error
StreamPeer
TCP
Winsock
::
put_data
(
const
uint8_t
*
p_data
,
int
p_bytes
)
{
int
total
;
return
write
(
p_data
,
p_bytes
,
total
,
true
);
};
Error
StreamPeerWinsock
::
put_partial_data
(
const
uint8_t
*
p_data
,
int
p_bytes
,
int
&
r_sent
)
{
Error
StreamPeer
TCP
Winsock
::
put_partial_data
(
const
uint8_t
*
p_data
,
int
p_bytes
,
int
&
r_sent
)
{
return
write
(
p_data
,
p_bytes
,
r_sent
,
false
);
};
Error
StreamPeerWinsock
::
get_data
(
uint8_t
*
p_buffer
,
int
p_bytes
)
{
Error
StreamPeer
TCP
Winsock
::
get_data
(
uint8_t
*
p_buffer
,
int
p_bytes
)
{
int
total
;
return
read
(
p_buffer
,
p_bytes
,
total
,
true
);
};
Error
StreamPeerWinsock
::
get_partial_data
(
uint8_t
*
p_buffer
,
int
p_bytes
,
int
&
r_received
)
{
Error
StreamPeer
TCP
Winsock
::
get_partial_data
(
uint8_t
*
p_buffer
,
int
p_bytes
,
int
&
r_received
)
{
return
read
(
p_buffer
,
p_bytes
,
r_received
,
false
);
};
StreamPeerTCP
::
Status
StreamPeerWinsock
::
get_status
()
const
{
StreamPeerTCP
::
Status
StreamPeer
TCP
Winsock
::
get_status
()
const
{
if
(
status
==
STATUS_CONNECTING
)
{
_poll_connection
();
...
...
@@ -255,7 +255,7 @@ StreamPeerTCP::Status StreamPeerWinsock::get_status() const {
return
status
;
};
bool
StreamPeerWinsock
::
is_connected_to_host
()
const
{
bool
StreamPeer
TCP
Winsock
::
is_connected_to_host
()
const
{
if
(
status
==
STATUS_NONE
||
status
==
STATUS_ERROR
)
{
...
...
@@ -268,7 +268,7 @@ bool StreamPeerWinsock::is_connected_to_host() const {
return
(
sockfd
!=
INVALID_SOCKET
);
};
void
StreamPeerWinsock
::
disconnect_from_host
()
{
void
StreamPeer
TCP
Winsock
::
disconnect_from_host
()
{
if
(
sockfd
!=
INVALID_SOCKET
)
closesocket
(
sockfd
);
...
...
@@ -281,7 +281,7 @@ void StreamPeerWinsock::disconnect_from_host() {
peer_port
=
0
;
};
void
StreamPeerWinsock
::
set_socket
(
int
p_sockfd
,
IP_Address
p_host
,
int
p_port
,
IP
::
Type
p_sock_type
)
{
void
StreamPeer
TCP
Winsock
::
set_socket
(
int
p_sockfd
,
IP_Address
p_host
,
int
p_port
,
IP
::
Type
p_sock_type
)
{
sockfd
=
p_sockfd
;
sock_type
=
p_sock_type
;
...
...
@@ -290,7 +290,7 @@ void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port,
peer_port
=
p_port
;
};
Error
StreamPeerWinsock
::
connect_to_host
(
const
IP_Address
&
p_host
,
uint16_t
p_port
)
{
Error
StreamPeer
TCP
Winsock
::
connect_to_host
(
const
IP_Address
&
p_host
,
uint16_t
p_port
)
{
ERR_FAIL_COND_V
(
!
p_host
.
is_valid
(),
ERR_INVALID_PARAMETER
);
...
...
@@ -331,13 +331,13 @@ Error StreamPeerWinsock::connect_to_host(const IP_Address &p_host, uint16_t p_po
return
OK
;
};
void
StreamPeerWinsock
::
set_nodelay
(
bool
p_enabled
)
{
void
StreamPeer
TCP
Winsock
::
set_nodelay
(
bool
p_enabled
)
{
ERR_FAIL_COND
(
!
is_connected_to_host
());
int
flag
=
p_enabled
?
1
:
0
;
setsockopt
(
sockfd
,
IPPROTO_TCP
,
TCP_NODELAY
,
(
char
*
)
&
flag
,
sizeof
(
int
));
}
int
StreamPeerWinsock
::
get_available_bytes
()
const
{
int
StreamPeer
TCP
Winsock
::
get_available_bytes
()
const
{
unsigned
long
len
;
int
ret
=
ioctlsocket
(
sockfd
,
FIONREAD
,
&
len
);
...
...
@@ -345,17 +345,17 @@ int StreamPeerWinsock::get_available_bytes() const {
return
len
;
}
IP_Address
StreamPeerWinsock
::
get_connected_host
()
const
{
IP_Address
StreamPeer
TCP
Winsock
::
get_connected_host
()
const
{
return
peer_host
;
};
uint16_t
StreamPeerWinsock
::
get_connected_port
()
const
{
uint16_t
StreamPeer
TCP
Winsock
::
get_connected_port
()
const
{
return
peer_port
;
};
StreamPeer
Winsock
::
StreamPeer
Winsock
()
{
StreamPeer
TCPWinsock
::
StreamPeerTCP
Winsock
()
{
sock_type
=
IP
::
TYPE_NONE
;
sockfd
=
INVALID_SOCKET
;
...
...
@@ -363,7 +363,7 @@ StreamPeerWinsock::StreamPeerWinsock() {
peer_port
=
0
;
};
StreamPeer
Winsock
::~
StreamPeer
Winsock
()
{
StreamPeer
TCPWinsock
::~
StreamPeerTCP
Winsock
()
{
disconnect_from_host
();
};
...
...
platform/windows/stream_peer
_winsock.h
→
drivers/windows/stream_peer_tcp
_winsock.h
View file @
cf7bd1a7
...
...
@@ -29,15 +29,15 @@
/*************************************************************************/
#ifdef WINDOWS_ENABLED
#ifndef STREAM_PEER_WINSOCK_H
#define STREAM_PEER_WINSOCK_H
#ifndef STREAM_PEER_
TCP_
WINSOCK_H
#define STREAM_PEER_
TCP_
WINSOCK_H
#include "error_list.h"
#include "core/io/ip_address.h"
#include "core/io/stream_peer_tcp.h"
class
StreamPeerWinsock
:
public
StreamPeerTCP
{
class
StreamPeer
TCP
Winsock
:
public
StreamPeerTCP
{
protected
:
mutable
Status
status
;
...
...
@@ -82,10 +82,10 @@ public:
virtual
void
set_nodelay
(
bool
p_enabled
);
StreamPeerWinsock
();
~
StreamPeerWinsock
();
StreamPeer
TCP
Winsock
();
~
StreamPeer
TCP
Winsock
();
};
#endif //
TCP_SOCKET_POSIX
_H
#endif //
STREAM_PEER_TCP_WINSOCK
_H
#endif
platform
/windows/tcp_server_winsock.cpp
→
drivers
/windows/tcp_server_winsock.cpp
View file @
cf7bd1a7
...
...
@@ -27,9 +27,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef WINDOWS_ENABLED
#include "tcp_server_winsock.h"
#include "stream_peer_winsock.h"
#include "stream_peer_
tcp_
winsock.h"
#include <winsock2.h>
#include <ws2tcpip.h>
...
...
@@ -151,7 +153,7 @@ Ref<StreamPeerTCP> TCPServerWinsock::take_connection() {
int
fd
=
accept
(
listen_sockfd
,
(
struct
sockaddr
*
)
&
their_addr
,
&
sin_size
);
ERR_FAIL_COND_V
(
fd
==
INVALID_SOCKET
,
NULL
);
Ref
<
StreamPeer
Winsock
>
conn
=
memnew
(
StreamPeer
Winsock
);
Ref
<
StreamPeer
TCPWinsock
>
conn
=
memnew
(
StreamPeerTCP
Winsock
);
IP_Address
ip
;
int
port
;
_set_ip_addr_port
(
ip
,
port
,
&
their_addr
);
...
...
@@ -181,3 +183,5 @@ TCPServerWinsock::~TCPServerWinsock() {
stop
();
};
#endif
platform
/windows/tcp_server_winsock.h
→
drivers
/windows/tcp_server_winsock.h
View file @
cf7bd1a7
...
...
@@ -27,6 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef WINDOWS_ENABLED
#ifndef TCP_SERVER_WINSOCK_H
#define TCP_SERVER_WINSOCK_H
...
...
@@ -54,3 +56,5 @@ public:
};
#endif
#endif
modules/enet/networked_multiplayer_enet.cpp
View file @
cf7bd1a7
...
...
@@ -386,7 +386,7 @@ int NetworkedMultiplayerENet::get_available_packet_count() const {
return
incoming_packets
.
size
();
}
Error
NetworkedMultiplayerENet
::
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
const
{
Error
NetworkedMultiplayerENet
::
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
{
ERR_FAIL_COND_V
(
incoming_packets
.
size
()
==
0
,
ERR_UNAVAILABLE
);
...
...
@@ -480,7 +480,7 @@ int NetworkedMultiplayerENet::get_max_packet_size() const {
return
1
<<
24
;
//anything is good
}
void
NetworkedMultiplayerENet
::
_pop_current_packet
()
const
{
void
NetworkedMultiplayerENet
::
_pop_current_packet
()
{
if
(
current_packet
.
packet
)
{
enet_packet_destroy
(
current_packet
.
packet
);
...
...
modules/enet/networked_multiplayer_enet.h
View file @
cf7bd1a7
...
...
@@ -86,12 +86,12 @@ private:
CompressionMode
compression_mode
;
mutable
List
<
Packet
>
incoming_packets
;
List
<
Packet
>
incoming_packets
;
mutable
Packet
current_packet
;
Packet
current_packet
;
uint32_t
_gen_unique_id
()
const
;
void
_pop_current_packet
()
const
;
void
_pop_current_packet
();
Vector
<
uint8_t
>
src_compressor_mem
;
Vector
<
uint8_t
>
dst_compressor_mem
;
...
...
@@ -123,7 +123,7 @@ public:
virtual
bool
is_server
()
const
;
virtual
int
get_available_packet_count
()
const
;
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
)
const
;
///< buffer is GONE after next get_packet
virtual
Error
get_packet
(
const
uint8_t
**
r_buffer
,
int
&
r_buffer_size
);
///< buffer is GONE after next get_packet
virtual
Error
put_packet
(
const
uint8_t
*
p_buffer
,
int
p_buffer_size
);
virtual
int
get_max_packet_size
()
const
;
...
...
platform/uwp/SCsub
View file @
cf7bd1a7
...
...
@@ -4,9 +4,6 @@ Import('env')
files
=
[
'thread_uwp.cpp'
,
'#platform/windows/tcp_server_winsock.cpp'
,
'#platform/windows/packet_peer_udp_winsock.cpp'
,
'#platform/windows/stream_peer_winsock.cpp'
,
'#platform/windows/key_mapping_win.cpp'
,
'#platform/windows/windows_terminal_logger.cpp'
,
'joypad_uwp.cpp'
,
...
...
platform/uwp/os_uwp.cpp
View file @
cf7bd1a7
...
...
@@ -34,13 +34,13 @@
#include "drivers/windows/dir_access_windows.h"
#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/mutex_windows.h"
#include "drivers/windows/packet_peer_udp_winsock.h"
#include "drivers/windows/rw_lock_windows.h"
#include "drivers/windows/semaphore_windows.h"
#include "drivers/windows/stream_peer_tcp_winsock.h"
#include "drivers/windows/tcp_server_winsock.h"
#include "io/marshalls.h"
#include "main/main.h"
#include "platform/windows/packet_peer_udp_winsock.h"
#include "platform/windows/stream_peer_winsock.h"
#include "platform/windows/tcp_server_winsock.h"
#include "platform/windows/windows_terminal_logger.h"
#include "project_settings.h"
#include "servers/audio_server.h"
...
...
@@ -163,7 +163,7 @@ void OSUWP::initialize_core() {
DirAccess
::
make_default
<
DirAccessWindows
>
(
DirAccess
::
ACCESS_FILESYSTEM
);
TCPServerWinsock
::
make_default
();
StreamPeerWinsock
::
make_default
();
StreamPeer
TCP
Winsock
::
make_default
();
PacketPeerUDPWinsock
::
make_default
();
// We need to know how often the clock is updated
...
...
platform/windows/SCsub
View file @
cf7bd1a7
...
...
@@ -19,9 +19,6 @@ common_win = [
"os_windows.cpp"
,
"ctxgl_procaddr.cpp"
,
"key_mapping_win.cpp"
,
"tcp_server_winsock.cpp"
,
"packet_peer_udp_winsock.cpp"
,
"stream_peer_winsock.cpp"
,
"joypad.cpp"
,
"power_windows.cpp"
,
"windows_terminal_logger.cpp"
...
...
platform/windows/os_windows.cpp
View file @
cf7bd1a7
...
...
@@ -34,19 +34,19 @@
#include "drivers/windows/dir_access_windows.h"
#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/mutex_windows.h"
#include "drivers/windows/packet_peer_udp_winsock.h"
#include "drivers/windows/rw_lock_windows.h"
#include "drivers/windows/semaphore_windows.h"
#include "drivers/windows/stream_peer_tcp_winsock.h"
#include "drivers/windows/tcp_server_winsock.h"
#include "drivers/windows/thread_windows.h"
#include "io/marshalls.h"
#include "joypad.h"
#include "lang_table.h"
#include "main/main.h"
#include "packet_peer_udp_winsock.h"
#include "servers/audio_server.h"
#include "servers/visual/visual_server_raster.h"
#include "servers/visual/visual_server_wrap_mt.h"
#include "stream_peer_winsock.h"
#include "tcp_server_winsock.h"
#include "version_generated.gen.h"
#include "windows_terminal_logger.h"
...
...
@@ -196,7 +196,7 @@ void OS_Windows::initialize_core() {
DirAccess
::
make_default
<
DirAccessWindows
>
(
DirAccess
::
ACCESS_FILESYSTEM
);
TCPServerWinsock
::
make_default
();
StreamPeerWinsock
::
make_default
();
StreamPeer
TCP
Winsock
::
make_default
();
PacketPeerUDPWinsock
::
make_default
();
// We need to know how often the clock is updated
...
...
@@ -1253,7 +1253,7 @@ void OS_Windows::finalize_core() {
memdelete
(
process_map
);
TCPServerWinsock
::
cleanup
();
StreamPeerWinsock
::
cleanup
();
StreamPeer
TCP
Winsock
::
cleanup
();
}
void
OS_Windows
::
alert
(
const
String
&
p_alert
,
const
String
&
p_title
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment