示例#1
0
        /// <summary>
        /// Acquires an appropriate event envelope.
        /// </summary>
        /// <returns></returns>
        private static MeshEvent Create(MeshEventType type)
        {
            // Get the appropriate packet
            switch (type)
            {
            case MeshEventType.Error:
            case MeshEventType.Ping:
            case MeshEventType.PingAck:
            case MeshEventType.HandshakeAck:
                return(MeshEvent.Acquire());

            case MeshEventType.Handshake:
                return(MeshHandshake.Acquire());

            case MeshEventType.GossipDigest:
            case MeshEventType.GossipSince:
            case MeshEventType.GossipUpdate:
                return(MeshGossip.Acquire());

            case MeshEventType.Subscribe:
            case MeshEventType.Unsubscribe:
            case MeshEventType.Custom:
                return(MeshEmitterEvent.Acquire());

            default:
                throw new InvalidOperationException("Unknown mesh packet");
            }
        }
示例#2
0
文件: MeshEx.cs 项目: toomasz/emitter
        /// <summary>
        /// Sends a mesh Handshake through the specified channel.
        /// </summary>
        /// <param name="channel">The channel to send the packet to.</param>
        internal static void SendMeshHandshake(this Connection channel)
        {
            // Acquire and set the handhshake packet
            var packet = MeshHandshake.Acquire();

            packet.Key      = Murmur32.GetHash(Service.Mesh.Cluster);
            packet.Identity = new GossipMember(Service.Mesh.BroadcastEndpoint);

            // Send the handshake packet
            channel.Send(packet);
        }