]> git.tdb.fi Git - libs/net.git/blobdiff - source/communicator.cpp
Style update: spaces around assignments
[libs/net.git] / source / communicator.cpp
index 2b20c6ec374932b993d70b2b5e6df4ea9745f59f..1bb0fde49592f81d9f9c2fa91a22a52431f45e7a 100644 (file)
@@ -41,7 +41,7 @@ HandshakeReceiver::HandshakeReceiver():
 
 void HandshakeReceiver::receive(const Handshake &shake)
 {
-       hash=shake.hash;
+       hash = shake.hash;
 }
 
 }
@@ -76,32 +76,32 @@ void Communicator::initiate_handshake()
                throw InvalidState("Handshaking is already underway or done");
 
        send_handshake();
-       handshake_status=1;
+       handshake_status = 1;
 }
 
 void Communicator::data_available()
 {
-       in_end+=socket.read(in_end, in_buf+buf_size-in_end);
+       in_end += socket.read(in_end, in_buf+buf_size-in_end);
        try
        {
-               bool more=true;
+               bool more = true;
                while(more)
                {
                        if(handshake_status==2)
                        {
-                               more=receive_packet(protocol, receiver);
+                               more = receive_packet(protocol, receiver);
                        }
                        else
                        {
                                HandshakeProtocol hsproto;
                                HandshakeReceiver hsrecv;
-                               if((more=receive_packet(hsproto, hsrecv)))
+                               if((more = receive_packet(hsproto, hsrecv)))
                                {
                                        if(hsrecv.get_hash()==protocol.get_hash())
                                        {
                                                if(handshake_status==0)
                                                        send_handshake();
-                                               handshake_status=2;
+                                               handshake_status = 2;
                                                signal_handshake_done.emit();
                                        }
                                        else
@@ -119,11 +119,11 @@ void Communicator::data_available()
 
 bool Communicator::receive_packet(const Protocol &proto, ReceiverBase &recv)
 {
-       int psz=proto.get_packet_size(in_begin, in_end-in_begin);
+       int psz = proto.get_packet_size(in_begin, in_end-in_begin);
        if(psz && psz<=in_end-in_begin)
        {
-               char *pkt=in_begin;
-               in_begin+=psz;
+               char *pkt = in_begin;
+               in_begin += psz;
                proto.disassemble(recv, pkt, psz);
                return true;
        }
@@ -131,10 +131,10 @@ bool Communicator::receive_packet(const Protocol &proto, ReceiverBase &recv)
        {
                if(in_end==in_buf+buf_size)
                {
-                       unsigned used=in_end-in_begin;
+                       unsigned used = in_end-in_begin;
                        memmove(in_buf, in_begin, used);
-                       in_begin=in_buf;
-                       in_end=in_begin+used;
+                       in_begin = in_buf;
+                       in_end = in_begin+used;
                }
                return false;
        }
@@ -143,10 +143,10 @@ bool Communicator::receive_packet(const Protocol &proto, ReceiverBase &recv)
 void Communicator::send_handshake()
 {
        Handshake shake;
-       shake.hash=protocol.get_hash();
+       shake.hash = protocol.get_hash();
 
        HandshakeProtocol hsproto;
-       unsigned size=hsproto.assemble(shake, out_buf, buf_size);
+       unsigned size = hsproto.assemble(shake, out_buf, buf_size);
        socket.write(out_buf, size);
 }