|
@@ -16,7 +16,7 @@ __declspec( dllexport ) Frame &Frame::operator+=( const Frame &b ) // baut frame
|
|
|
{
|
|
|
char *data = new char[ (int)dataLength ];
|
|
|
if( data )
|
|
|
- memcpy( data, this->data, (int)(dataLength - b.dataLength) );
|
|
|
+ memcpy( data, this->data, (int)( dataLength - b.dataLength ) );
|
|
|
if( b.data )
|
|
|
memcpy( data + dataLength, b.data, (int)b.dataLength );
|
|
|
delete[] this->data;
|
|
@@ -90,7 +90,7 @@ __declspec( dllexport ) bool WebSocketClient::connect()
|
|
|
klient = new Klient();
|
|
|
if( !klient->verbinde( port, host ) )
|
|
|
{
|
|
|
- klient = klient->release();
|
|
|
+ klient = (Klient *)klient->release();
|
|
|
return 0;
|
|
|
}
|
|
|
klient->sende( message, message.getLength() );
|
|
@@ -113,7 +113,7 @@ __declspec( dllexport ) bool WebSocketClient::connect()
|
|
|
if( handshakeResponse->getStatusCode() != 101 )
|
|
|
{
|
|
|
handshakeResponse->release();
|
|
|
- klient = klient->release();
|
|
|
+ klient = (Klient *)klient->release();
|
|
|
return 0;
|
|
|
}
|
|
|
handshakeResponse->release();
|
|
@@ -139,10 +139,10 @@ __declspec( dllexport ) bool WebSocketClient::send( __int64 size, const char *da
|
|
|
f.dataLength = size;
|
|
|
f.data = new char[ (int)f.dataLength ];
|
|
|
memcpy( f.data, data, (int)f.dataLength );
|
|
|
- f.key[ 0 ] = (unsigned char)(gen.rand() * 256);
|
|
|
- f.key[ 1 ] = (unsigned char)(gen.rand() * 256);
|
|
|
- f.key[ 2 ] = (unsigned char)(gen.rand() * 256);
|
|
|
- f.key[ 3 ] = (unsigned char)(gen.rand() * 256);
|
|
|
+ f.key[ 0 ] = (unsigned char)( gen.rand() * 256 );
|
|
|
+ f.key[ 1 ] = (unsigned char)( gen.rand() * 256 );
|
|
|
+ f.key[ 2 ] = (unsigned char)( gen.rand() * 256 );
|
|
|
+ f.key[ 3 ] = (unsigned char)( gen.rand() * 256 );
|
|
|
c.lock();
|
|
|
queue->add( f );
|
|
|
c.unlock();
|
|
@@ -175,50 +175,50 @@ __declspec( dllexport ) void WebSocketClient::thread()
|
|
|
return;
|
|
|
}
|
|
|
Frame message;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.fin = ( byte & 0x80 ) != 0;
|
|
|
message.rsv1 = ( byte & 0x40 ) != 0;
|
|
|
message.rsv2 = ( byte & 0x20 ) != 0;
|
|
|
message.rsv3 = ( byte & 0x10 ) != 0;
|
|
|
message.opcode = byte & 0xF;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.mask = ( byte & 0x80 ) != 0;
|
|
|
message.dataLength = byte & 0x7F;
|
|
|
if( message.dataLength == 126 )
|
|
|
{
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength = byte << 8;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength |= byte;
|
|
|
}
|
|
|
else if( message.dataLength == 127 )
|
|
|
{
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength = (__int64)byte << 56;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength |= (__int64)byte << 48;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength |= (__int64)byte << 40;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength |= (__int64)byte << 32;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength |= (__int64)byte << 24;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength |= (__int64)byte << 16;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength |= (__int64)byte << 8;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.dataLength |= (__int64)byte;
|
|
|
}
|
|
|
if( message.mask )
|
|
|
{
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.key[ 0 ] = byte;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.key[ 1 ] = byte;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.key[ 2 ] = byte;
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
message.key[ 3 ] = byte;
|
|
|
}
|
|
|
if( !ok )
|
|
@@ -228,7 +228,7 @@ __declspec( dllexport ) void WebSocketClient::thread()
|
|
|
message.data = new char[ (int)message.dataLength ];
|
|
|
for( int i = 0; i < message.dataLength; i++ )
|
|
|
{
|
|
|
- ok &= klient->getNachricht( (char*)&byte, 1 );
|
|
|
+ ok &= klient->getNachricht( (char *)&byte, 1 );
|
|
|
if( message.mask )
|
|
|
message.data[ i ] = byte ^ message.key[ i % 4 ];
|
|
|
else
|
|
@@ -271,7 +271,7 @@ __declspec( dllexport ) void WebSocketClient::thread()
|
|
|
delete[] m.data;
|
|
|
c2.lock();
|
|
|
klient->trenne();
|
|
|
- klient = klient->release();
|
|
|
+ klient = (Klient *)klient->release();
|
|
|
c2.unlock();
|
|
|
return;
|
|
|
}
|
|
@@ -310,7 +310,7 @@ __declspec( dllexport ) void WebSocketClient::thread()
|
|
|
c2.unlock();
|
|
|
return;
|
|
|
}
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = ( f.mask ? 1 : 0 ) << 7;
|
|
|
if( f.dataLength < 126 )
|
|
|
byte |= (unsigned char)f.dataLength & 0x7F;
|
|
@@ -318,46 +318,46 @@ __declspec( dllexport ) void WebSocketClient::thread()
|
|
|
byte |= 126;
|
|
|
else
|
|
|
byte |= 127;
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
if( f.dataLength >= 126 )
|
|
|
{
|
|
|
if( f.dataLength <= 32767 )
|
|
|
{
|
|
|
byte = (unsigned char)( f.dataLength >> 8 );
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)f.dataLength & 0xFF;
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
byte = (unsigned char)( f.dataLength >> 56 );
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)( f.dataLength >> 48 );
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)( f.dataLength >> 40 );
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)( f.dataLength >> 32 );
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)( f.dataLength >> 24 );
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)( f.dataLength >> 16 );
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)( f.dataLength >> 8 );
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)f.dataLength & 0xFF;
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
}
|
|
|
}
|
|
|
if( f.mask )
|
|
|
{
|
|
|
byte = (unsigned char)f.key[ 0 ];
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)f.key[ 1 ];
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)f.key[ 2 ];
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
byte = (unsigned char)f.key[ 3 ];
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
}
|
|
|
if( f.dataLength )
|
|
|
{
|
|
@@ -367,7 +367,7 @@ __declspec( dllexport ) void WebSocketClient::thread()
|
|
|
byte = (unsigned char)f.data[ i ] ^ f.key[ i % 4 ];
|
|
|
else
|
|
|
byte = (unsigned char)f.data[ i ];
|
|
|
- klient->sende( (char*)&byte, 1 );
|
|
|
+ klient->sende( (char *)&byte, 1 );
|
|
|
}
|
|
|
}
|
|
|
c2.unlock();
|
|
@@ -381,7 +381,7 @@ __declspec( dllexport ) void WebSocketClient::thread()
|
|
|
c.unlock();
|
|
|
c2.lock();
|
|
|
klient->trenne();
|
|
|
- klient = klient->release();
|
|
|
+ klient = (Klient *)klient->release();
|
|
|
c2.unlock();
|
|
|
return;
|
|
|
}
|
|
@@ -402,7 +402,7 @@ __declspec( dllexport ) void WebSocketClient::disconnect()
|
|
|
return;
|
|
|
c2.lock();
|
|
|
klient->trenne();
|
|
|
- klient = klient->release();
|
|
|
+ klient = (Klient *)klient->release();
|
|
|
c2.unlock();
|
|
|
warteAufThread( 1000 );
|
|
|
}
|
|
@@ -410,14 +410,4 @@ __declspec( dllexport ) void WebSocketClient::disconnect()
|
|
|
__declspec( dllexport ) bool WebSocketClient::isConnected() const
|
|
|
{
|
|
|
return klient != 0;
|
|
|
-}
|
|
|
-
|
|
|
-// löscht das objekt wenn es nicht mehr gebraucht wird und beendet den Thread
|
|
|
-Thread *WebSocketClient::release()
|
|
|
-{
|
|
|
-#ifdef WIN32
|
|
|
- if( ref == 2 && run )
|
|
|
- disconnect();
|
|
|
-#endif
|
|
|
- return Thread::release();
|
|
|
}
|