Exemple #1
0
        //, bool reliable, uint channel)
        //TODO Connection zu Netcomputer zusammenfassen?
        public void send(MessageOut msg)
        {
            NetworkStream stream=mRemote.GetStream();

            //Länge senden
            ushort lengthPackage=(ushort)msg.getLength();
            byte[] lengthAsByteArray=BitConverter.GetBytes(lengthPackage);
            stream.Write(lengthAsByteArray, 0, (int)lengthAsByteArray.Length);

            stream.Write(msg.getData(), 0, (int)msg.getLength());

            //if (!mRemote) {
            //    LOG_WARN("Can't send message to unconnected host! (" << msg << ")");
            //    return;
            //}

            //gBandwidth.increaseInterServerOutput(msg.getLength());

            //ENetPacket *packet;
            //packet = enet_packet_create(msg.getData(),
            //                            msg.getLength(),
            //                            reliable ? ENET_PACKET_FLAG_RELIABLE : 0);

            //if (packet)
            //    enet_peer_send(mRemote, channel, packet);
            //else
            //    LOG_ERROR("Failure to create packet!");
        }
Exemple #2
0
        public void send(MessageOut msg)
        {
            NetworkStream stream=mPeer.GetStream();

            //Daten in Websocketformat verpacken
            byte[] wsMsg=Websocket.GetWebsocketDataFrame(msg.getData());

            try
            {
                stream.Write(wsMsg);
                Logger.Write(LogLevel.Debug, "Sending message {0} to {1}", msg, this);
            }
            catch(IOException ex)
            {
                if(((SocketException)(ex.InnerException)).ErrorCode==10053)
                {
                    Logger.Write(LogLevel.Warning, "An established connection was aborted by the software in your host machine.");
                }
            }
        }
Exemple #3
0
        public void send(MessageOut msg, bool reliable, uint channel)
        {
            Logger.Write(LogLevel.Debug, "Sending message {0} to {1}", msg, this);

            //gBandwidth.increaseClientOutput(this, msg.getLength());

            NetworkStream stream=mPeer.GetStream();

            //Länge senden
            ushort lengthPackage=(ushort)msg.getLength();
            byte[] lengthAsByteArray=BitConverter.GetBytes(lengthPackage);
            stream.Write(lengthAsByteArray, 0, (int)lengthAsByteArray.Length);

            //TODO Überprüfung ob Länge größer ushort dann Problem
            stream.Write(msg.getData(), 0, (int)msg.getLength());

            //if(packet)
            //{
            //    enet_peer_send(mPeer, channel, packet);
            //}
            //else
            //{
            //    LOG_ERROR("Failure to create packet!");
            //}
        }
Exemple #4
0
        public void send(MessageOut msg)
        {
            NetworkStream stream=mRemote.GetStream();

            //In Websocketpaket packen
            byte[] wsMsg=Websocket.GetWebsocketDataFrame(msg.getData());
            stream.Write(wsMsg);

            if(mRemote==null)
            {
                Logger.Write(LogLevel.Warning, "Can't send message to unconnected host! ({0})", msg);
                return;
            }
            else
            {
                Logger.Write(LogLevel.Debug, "Sending message {0} to {1}", msg, mRemote.Client.RemoteEndPoint);
            }

            Program.gBandwidth.increaseInterServerOutput((int)msg.getLength());
        }