Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
03847a9b
Commit
03847a9b
authored
Apr 21, 2009
by
Max-Wilhelm Bruker
Browse files
fixed socket bug and simplified readClient()
parent
b4fd5797
Changes
3
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/client.cpp
View file @
03847a9b
...
...
@@ -2,13 +2,12 @@
#include
"client.h"
Client
::
Client
(
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
MsgId
(
0
)
{
timer
=
new
QTimer
(
this
);
timer
->
setInterval
(
1000
);
connect
(
timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
checkTimeout
()));
MsgId
=
0
;
status
=
StatusDisconnected
;
socket
=
new
QTcpSocket
(
this
);
socket
->
setTextModeEnabled
(
true
);
...
...
servatrice/src/main.cpp
View file @
03847a9b
...
...
@@ -20,6 +20,7 @@
#include
<QCoreApplication>
#include
<QTextCodec>
#include
"server.h"
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -27,6 +28,8 @@ int main(int argc, char *argv[])
QCoreApplication
app
(
argc
,
argv
);
app
.
setOrganizationName
(
"Cockatrice"
);
app
.
setApplicationName
(
"Servatrice"
);
QTextCodec
::
setCodecForCStrings
(
QTextCodec
::
codecForName
(
"UTF-8"
));
Server
server
;
if
(
!
server
.
openDatabase
())
{
...
...
servatrice/src/serversocket.cpp
View file @
03847a9b
...
...
@@ -142,25 +142,11 @@ void ServerSocket::leaveGame()
void
ServerSocket
::
readClient
()
{
QTextStream
*
stream
=
new
QTextStream
(
this
);
stream
->
setCodec
(
"UTF-8"
);
QStringList
lines
;
// Before parsing, everything has to be buffered so that the stream
// can be deleted in order to avoid problems when moving the object
// to another thread while this function is still running.
for
(;;)
{
QString
line
=
stream
->
readLine
();
while
(
canReadLine
())
{
QString
line
=
QString
(
readLine
()).
trimmed
();
if
(
line
.
isNull
())
break
;
lines
<<
line
;
}
delete
stream
;
QStringListIterator
i
(
lines
);
while
(
i
.
hasNext
())
{
QString
line
=
i
.
next
();
qDebug
(
QString
(
"<<< %1"
).
arg
(
line
).
toLatin1
());
switch
(
PlayerStatus
)
{
case
StatusNormal
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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