예제 #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);
        }