Exemple #1
0
        public void Send(byte[] data, Instance address = null, SocketMessageType type = SocketMessageType.Data)
        {
            var buffer = EndPointMessage.Write(new EndPointMessage()
            {
                SenderName     = instance.Id.ToString(),
                SenderEndPoint = endPoint,
                Type           = type,
                Data           = data
            });

            if (type == SocketMessageType.Login)
            {
                Instance.DBTable.Load();
            }

            foreach (Instance item in Instance.DBTable)
            {
                if (address == null || item == address)
                {
                    if (item.Active.Value && item.EndPoint != null && !item.EndPoint.Equals(endPoint) && !IPAddress.Loopback.Equals(item.EndPoint.Address))
                    {
                        Send(buffer, item.EndPoint);
                    }
                }
            }
        }
Exemple #2
0
        public void Send(NotifyMessageItem[] items, IInstance address = null)
        {
            var buffer = (byte[])null;

            foreach (IInstance item in Instance.DBTable)
            {
                if (CheckAddress(item, address))
                {
                    if (buffer == null)
                    {
                        buffer = EndPointMessage.Write(new EndPointMessage
                        {
                            SenderName     = instance.Id.ToString(),
                            SenderEndPoint = endPoint,
                            Type           = SocketMessageType.Data,
                            Data           = Serialize(items)
                        });
                    }
                    Send(buffer, item.EndPoint, item);
                }
            }
        }
Exemple #3
0
        public void Send(byte[] data, IInstance address = null, SocketMessageType type = SocketMessageType.Data, bool checkState = false)
        {
            var buffer = EndPointMessage.Write(new EndPointMessage()
            {
                SenderName     = instance.Id.ToString(),
                SenderEndPoint = endPoint,
                Type           = type,
                Data           = data
            });

            if (type == SocketMessageType.Login)
            {
                Instance.DBTable.Load();
            }

            foreach (IInstance item in Instance.DBTable)
            {
                if (CheckAddress(item, address, checkState))
                {
                    Send(buffer, item.EndPoint, item);
                }
            }
        }