/// <summary>
        /// Sends the byte[] message and uses the specified flags to configure the sending behavior.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="message">The byte array to send</param>
        /// <param name="flags">Send flags configuring the sending operation</param>
        public static void Send(this IZmqSocket source, byte[] message, SendFlags flags)
        {
            bool hasMore   = (flags & SendFlags.SendMore) != 0;
            bool doNotWait = (flags & SendFlags.DoNotWait) != 0;

            source.Send(message, hasMore, doNotWait);
        }
Beispiel #2
0
        /// <summary>
        /// Sends data over the socket with flags set.
        /// </summary>
        /// <param name="flags"></param>
        /// <param name="data">The message part(s). Sending without a value set will result in sending a zero-length message, not a null.</param>
        /// <returns>True if the data was sent successfully; otherwise, false.</returns>
        public bool Send(SendFlags flags, params byte[][] data)
        {
            Contract.Requires(!Disposed);

            if (data.Length == 0)
            {
                return(SendOne(new byte[0], flags));
            }
            if (data.Length == 1)
            {
                return(SendOne(data[0], flags));
            }
            else if (data.Length > 1)
            {
                for (int i = 0; i < data.Length - 1; i++)
                {
                    if (SendOne(data[i], flags | SendFlags.MoreToFollow) == false)
                    {
                        return(false);
                    }
                }

                return(SendOne(data.Last(), flags));
            }

            return(true);
        }
        public Result SendMessageToConnection(Connection connection, byte[] data, SendFlags flags)
        {
            if (data == null)
                throw new ArgumentNullException("data");

            return SendMessageToConnection(connection, data, data.Length, flags);
        }
Beispiel #4
0
        public override void Send(byte[] buffer, SendFlags flags)
        {
            if (Disconnected || !socket.Connected)
            {
                return;
            }

            // TODO: Low priority sending support
            try {
                if ((flags & SendFlags.Synchronous) != 0)
                {
                    socket.Send(buffer, 0, buffer.Length, SocketFlags.None);
                    return;
                }

                lock (sendLock) {
                    if (sendInProgress)
                    {
                        sendQueue.Enqueue(buffer);
                    }
                    else
                    {
                        sendInProgress = TrySendAsync(buffer);
                    }
                }
            } catch (SocketException) {
                Disconnect();
            } catch (ObjectDisposedException) {
                // Socket was already closed by another thread
            }
        }
Beispiel #5
0
        private bool SendOne(byte[] data, SendFlags flags)
        {
            Contract.Requires(!Disposed);
            Contract.Requires(data != null);

            if (C.zmq_msg_init_size(m_msg, data.Length) != 0)
            {
                throw ZeroMQException.CurrentError();
            }

            Marshal.Copy(data, 0, C.zmq_msg_data(m_msg), data.Length);
            int rc = C.zmq_send(m_sock, m_msg, (int)flags);

            C.zmq_msg_close(m_msg);

            if (rc == 0)
            {
                return(true);
            }
            else if (C.zmq_errno() == C.EAGAIN)
            {
                return(false);
            }
            else
            {
                throw ZeroMQException.CurrentError();
            }
        }
 public void Send(Byte[] data, SendFlags flags, OnSent onSent)
 {
     if (connected)
     {
         client.SendMessageToConnection(connection, data, flags);
         onSent?.Invoke();
     }
 }
 public override void Send(byte[] buffer, SendFlags flags)
 {
     try {
         lock (locker) ssl.Write(buffer);
     } catch (Exception ex) {
         Logger.LogError("Error writing to secure stream", ex);
     }
 }
Beispiel #8
0
 public void SendToAll(Byte[] data, SendFlags flags)
 {
     if (ServerActive())
     {
         foreach (UInt32 connectedId in connectedClients.ToArray())
         {
             SendTo(connectedId, data, flags);
         }
     }
 }
Beispiel #9
0
 public void SendToAllPlayers(Byte[] data, SendFlags flags)
 {
     if (ServerActive())
     {
         foreach (Player player in sgr.pm.players)
         {
             SendTo(player.id, data, flags);
         }
     }
 }
Beispiel #10
0
        private bool SendMail(string subject, string body, SendFlags flags)
        {
            MapiMessage message = new MapiMessage();

            message.subject  = subject;
            message.noteText = body;
            message.recips   = GetRecipients(out message.recipCount);
            message.files    = GetAttachments(out message.fileCount);

            lastError = (MessageApiError)MAPISendMail(IntPtr.Zero, IntPtr.Zero, message, flags, 0);
            Cleanup(message);
            return(lastError == MessageApiError.Success);
        }
Beispiel #11
0
 public void SendTo(int playerID, NetworkPacket sendData, int timeOut, out int asyncHandle, SendFlags flags, object context)
 {
     throw new NotImplementedException();
 }
        public Result SendMessageToConnection(Connection connection, byte[] data, int length, SendFlags flags)
        {
            if (data == null)
                throw new ArgumentNullException("data");

            return Native.SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(nativeSockets, connection, data, (uint)length, flags, IntPtr.Zero);
        }
 internal static extern Result SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(IntPtr sockets, Connection connection, byte[] data, uint length, SendFlags flags, IntPtr outMessageNumber);
Beispiel #14
0
 public void Send(NetworkPacket sendData, int timeOut, out int asyncHandle, SendFlags flags)
 {
     throw new NotImplementedException();
 }
Beispiel #15
0
 public void SendTo(UInt32 connectionID, string data, SendFlags flags)
 {
     SendTo(connectionID, Encoding.ASCII.GetBytes(data), flags);
 }
Beispiel #16
0
 /// <summary> Sends a block of data. </summary>
 public abstract void Send(byte[] buffer, SendFlags flags);
Beispiel #17
0
 public void Send(GCHandle gcbuffer, int bufferSize, int timeOut, out int asyncHandle, SendFlags flags)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
 public void SendTo(int playerID, GCHandle gcbuffer, int bufferSize, int timeOut, SendFlags flags)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
 private static extern int MAPISendMail(IntPtr session, IntPtr hWnd, MapiMessage message, SendFlags flags, uint reserved);
Beispiel #20
0
        /// <summary>
        /// Sends data over the socket with flags set.
        /// </summary>
        /// <param name="flags"></param>
        /// <param name="data">The message part(s). Sending without a value set will result in sending a zero-length message, not a null.</param>
        /// <returns>True if the data was sent successfully; otherwise, false.</returns>
        public bool Send( SendFlags flags, params byte[][] data )
        {
            Contract.Requires( !Disposed );

            if( data.Length == 0 )
            {
                return SendOne( new byte[0], flags );
            }
            if( data.Length == 1 )
            {
                return SendOne( data[0], flags );
            }
            else if( data.Length > 1 )
            {
                for( int i = 0; i < data.Length - 1; i++ )
                {
                    if( SendOne( data[i], flags | SendFlags.MoreToFollow ) == false )
                    {
                        return false;
                    }
                }

                return SendOne( data.Last(), flags );
            }

            return true;
        }
Beispiel #21
0
        private bool SendOne( byte[] data, SendFlags flags )
        {
            Contract.Requires( !Disposed );
            Contract.Requires( data != null );

            if( C.zmq_msg_init_size( m_msg, data.Length ) != 0 )
            {
                throw ZeroMQException.CurrentError();
            }

            Marshal.Copy( data, 0, C.zmq_msg_data( m_msg ), data.Length );
            int rc = C.zmq_send( m_sock, m_msg, (int)flags );

            C.zmq_msg_close( m_msg );

            if( rc == 0 )
            {
                return true;
            }
            else if( C.zmq_errno() == C.EAGAIN )
            {
                return false;
            }
            else
            {
                throw ZeroMQException.CurrentError();
            }
        }
Beispiel #22
0
 private static extern int MAPISendMail(IntPtr session, IntPtr hWnd, MapiMessage message, SendFlags flags, uint reserved);
Beispiel #23
0
        private bool SendMail(string subject, string body, SendFlags flags)
        {
            MapiMessage message = new MapiMessage();
            message.subject = subject;
            message.noteText = body;
            message.recips = GetRecipients(out message.recipCount);
            message.files = GetAttachments(out message.fileCount);

            lastError = (MessageApiError)MAPISendMail(IntPtr.Zero, IntPtr.Zero, message, flags, 0);
            Cleanup(message);
            return lastError == MessageApiError.Success;
        }
Beispiel #24
0
 public void SendTo(UInt32 connectionID, byte[] data, SendFlags flags)
 {
     server.SendMessageToConnection(connectionID, data, flags);
 }
Beispiel #25
0
 protected override void SendRaw(byte[] data, SendFlags flags)
 {
     s.Send(data, flags);
 }
Beispiel #26
0
 protected override void SendRaw(byte[] data, SendFlags flags)
 {
     lock (sendLock) stream.Write(data);
 }
Beispiel #27
0
 public override void Send(byte[] buffer, SendFlags flags)
 {
     s.Send(WrapData(buffer), flags);
 }
 public Result SendMessageToConnection(Connection connection, IntPtr data, uint length, SendFlags flags)
 {
     return SendMessageToConnection(connection, data, length, flags);
 }
Beispiel #29
0
 public void Send(GCHandle gcbuffer, int bufferSize, int timeOut, SendFlags flags, object context)
 {
     throw new NotImplementedException();
 }
 public Result SendMessageToConnection(Connection connection, IntPtr data, int length, SendFlags flags)
 {
     return Native.SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(nativeSockets, connection, data, (uint)length, flags, IntPtr.Zero);
 }
Beispiel #31
0
 public void Send(NetworkPacket sendData, int timeOut, SendFlags flags, object context)
 {
     throw new NotImplementedException();
 }
Beispiel #32
0
 public void SendTo(int playerID, NetworkPacket sendData, int timeOut, SendFlags flags)
 {
     throw new NotImplementedException();
 }
Beispiel #33
0
 public void SendTo(int playerID, GCHandle gcbuffer, int bufferSize, int timeOut, out int asyncHandle, SendFlags flags, object context)
 {
     throw new NotImplementedException();
 }
Beispiel #34
0
 /// <summary> Sends data to the underlying socket without wrapping the data in a websocket frame </summary>
 protected abstract void SendRaw(byte[] data, SendFlags flags);