Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Commit

Permalink
Fixed channel subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Lang committed Jul 15, 2013
1 parent c9aa5cb commit c781bc8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Pusher/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override Type GetDataType()
}

[DataContract]
public class Event
public class Event : IEvent
{
[DataMember(Name = "event")]
public string EventName { get; set; }
Expand Down
20 changes: 17 additions & 3 deletions Pusher/Events/SubscribeEvent.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
using System.Runtime.Serialization;
using System;
using System.Runtime.Serialization;

namespace Pusher.Events
{
[DataContract]
public class SubscribeEvent : Event<SubscribeEventArgs>
public class SubscribeEvent : IEvent
{
public SubscribeEvent(string channel)
{
EventName = Pusher.EventSubscribe;
DataObject = new SubscribeEventArgs { Channel = channel };
DataObject = new SubscribeEventArgs { Channel = channel };
}

[DataMember(Name = "event")]
public string EventName { get; set; }

public string Channel { get; set; }

public Type GetDataType()
{
return typeof (SubscribeEventArgs);
}

[DataMember(Name = "data")]
public SubscribeEventArgs DataObject { get; set; }
}
}
16 changes: 16 additions & 0 deletions Pusher/IEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Runtime.Serialization;

namespace Pusher
{
public interface IEvent
{
[DataMember(Name = "event")]
string EventName { get; set; }

[DataMember(Name = "channel", EmitDefaultValue = false, IsRequired = false)]
string Channel { get; set; }

Type GetDataType();
}
}
2 changes: 1 addition & 1 deletion Pusher/Pusher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void ReceivedEvent(object sender, DataReceivedEventArgs dataReceivedEven
}
}

internal async Task TriggerEventAsync(Event e)
internal async Task TriggerEventAsync(IEvent e)
{
var json = JsonConvert.SerializeObject(e);
_logger.Debug("Sending event {0} to {1}: {2}", e.EventName, e.Channel ?? "all channels", json);
Expand Down
1 change: 1 addition & 0 deletions Pusher/Pusher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Compile Include="IAuthenticator.cs" />
<Compile Include="IConnection.cs" />
<Compile Include="IConnectionFactory.cs" />
<Compile Include="IEvent.cs" />
<Compile Include="IEventContract.cs" />
<Compile Include="ILogger.cs" />
<Compile Include="Logger.cs" />
Expand Down

0 comments on commit c781bc8

Please sign in to comment.