InANonExtensibleAndNonConfigurableManner

12 views
Skip to first unread message

Слава

unread,
Nov 9, 2010, 2:11:47 AM11/9/10
to aspComet
Hi.


How to register event handlers and send message to all client from
server after calling InANonExtensibleAndNonConfigurableManner?

Neil Mosafi

unread,
Nov 9, 2010, 7:42:16 AM11/9/10
to aspComet
You could do something like this

EventHub.Subscribe<WhichEventYouWant>(e =>
{

ServiceLocator.Current.GetInstance<IClientRepository>().WhereSubscribedTo("channel").Enqueue(message);
};

Seems there's no All() method on the client repository, should
probably add that!

Слава Антонов

unread,
Nov 9, 2010, 8:05:57 AM11/9/10
to aspc...@googlegroups.com
Can I send message to client not from event handler? From timer for example.


--
Всего хорошего.
Отправлено с iPhone

09.11.2010, в 18:42, Neil Mosafi <nmo...@gmail.com> написал(а):

Neil Mosafi

unread,
Nov 9, 2010, 8:06:42 AM11/9/10
to aspComet
Yes should be fine. Once you enqueue the message, flush the queue,
that will cause the message to be sent immediately and his browser
will start a new long polling connection straight away after receiving
it, ready for the next message.

On Nov 9, 1:05 pm, Слава Антонов <bedd...@gmail.com> wrote:
> Can I send message to client not from event handler? From timer for example.
>
> --
> Всего хорошего.
> Отправлено с iPhone
>
> 09.11.2010, в 18:42, Neil Mosafi <nmos...@gmail.com> написал(а):

Слава Антонов

unread,
Nov 10, 2010, 2:05:30 AM11/10/10
to aspc...@googlegroups.com
I am trying something like this:

protected void Application_Start()
{
// ...
  Setup.AspComet.InANonExtensibleAndNonConfigurableManner();
  AspComet.Eventing.EventHub.Subscribe<PublishingEvent>(CometServ.OnMessage);
  CometServ.CometClients = ServiceLocator.Current.GetInstance<IClientRepository>();
        
}
And I'm have an exception: "DummyServiceLocator does not support retrieving anything but the message bus"

2010/11/9 Neil Mosafi <nmo...@gmail.com>

Yes should be fine. Once you enqueue the message, flush the queue,
that will cause the message to be sent immediately and his browser
will start a new long polling connection straight away after receiving
it, ready for the next message.



--
Всего хорошего, Слава.

Neil Mosafi

unread,
Nov 10, 2010, 8:39:59 AM11/10/10
to aspComet
Ahh you're right! That needs implementing. Can you create an issue
for this on https://github.com/nmosafi/aspcomet/issues

Thanks
Neil

On Nov 10, 7:05 am, Слава Антонов <bedd...@gmail.com> wrote:
> I am trying something like this:
>
> protected void Application_Start()
> {
>   // ...
>
>   Setup.AspComet.InANonExtensibleAndNonConfigurableManner();
>
>   AspComet.Eventing.EventHub.Subscribe<PublishingEvent>(CometServ.OnMessage);
>
>   CometServ.CometClients =
> ServiceLocator.Current.GetInstance<IClientRepository>();
>
> }
>
> And I'm have an exception: "DummyServiceLocator does not support
> retrieving anything but the message bus"
>
> 2010/11/9 Neil Mosafi <nmos...@gmail.com>

Neil Mosafi

unread,
Nov 10, 2010, 6:41:52 PM11/10/10
to aspComet
OK I fixed this. See the following checkin

https://github.com/nmosafi/aspComet/commit/beccea517c1b0d4eaf3273d51de8f8b9dd4d998c

Also renamed the method!

Thanks
Neil

On Nov 10, 1:39 pm, Neil Mosafi <nmos...@gmail.com> wrote:
> Ahh you're right! That needs implementing.  Can you create an issue
> for this onhttps://github.com/nmosafi/aspcomet/issues

Слава Антонов

unread,
Nov 11, 2010, 2:17:55 AM11/11/10
to aspc...@googlegroups.com
Thank You.
But now I need something like this:

        public static void Enqueue(this IClient client, string sender, string channel, string message)
        {
          
            Dictionary<stringstring> MsgData = new Dictionary<string,string>();
            MsgData.Add("sender", sender);
            MsgData.Add("message", message);

            Message Msg = new Message();
            Msg.channel = channel;
            Msg.data = MsgData;

            client.Enqueue(Msg);
            client.FlushQueue();
        }

This allows send message to client from server-side
I want use AspComet to push some data from server to clients in real time

2010/11/11 Neil Mosafi <nmo...@gmail.com>



--
Всего хорошего, Слава.

Neil Mosafi

unread,
Nov 26, 2010, 5:46:11 PM11/26/10
to aspComet
Hi Слава

How did you get on with this?

On Nov 11, 7:17 am, Слава Антонов <bedd...@gmail.com> wrote:
> Thank You.
> But now I need something like this:
>
>         public static void Enqueue(this IClient client, string sender,
> string channel, string message)
>         {
>
>             Dictionary<string, string> MsgData = new
> Dictionary<string,string>();
>             MsgData.Add("sender", sender);
>             MsgData.Add("message", message);
>
>             Message Msg = new Message();
>             Msg.channel = channel;
>             Msg.data = MsgData;
>
>             client.Enqueue(Msg);
>             client.FlushQueue();
>         }
>
> This allows send message to client from server-side
>
> I want use AspComet to push some data from server to clients in real time
>
> 2010/11/11 Neil Mosafi <nmos...@gmail.com>
>
>
>
>
>
>
>
>
>
> > OK I fixed this. See the following checkin
>
> >https://github.com/nmosafi/aspComet/commit/beccea517c1b0d4eaf3273d51d...

Слава Антонов

unread,
Nov 27, 2010, 8:24:36 PM11/27/10
to aspc...@googlegroups.com
Fine. Its working for me :)

But I have big ploblem with 'Handhake successful? True. System: Request on channel /meta/connect failed: No message' error.
It occurs very frequent: after refresh client page, or after connecting/disconnecting other client (especialy in IE8)
 
2010/11/27 Neil Mosafi <nmo...@gmail.com>

How did you get on with this?



--
Всего хорошего, Слава.

Слава Антонов

unread,
Dec 1, 2010, 1:58:48 AM12/1/10
to aspc...@googlegroups.com
Some info.

I see "A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll" in VS Output window every time when client see "System: Request on channel /meta/connect failed: No message"

I add breakpoint for this exception and VS shows me that it occurs in line "this.callback(this);" of 
public void CompleteRequestWithMessages(IEnumerable<Message> responseMessages) method in CometAsyncResult.cs.

Exception message is "An existing connection was forcibly closed by the remote host"

PS: I am using AspComet in ASP.NET MVC2 application.


2010/11/28 Слава Антонов <bed...@gmail.com>



--
Всего хорошего, Слава.

Слава Антонов

unread,
Dec 1, 2010, 2:16:25 AM12/1/10
to aspc...@googlegroups.com
Hmm.

This is fix for my problem:

public void CompleteRequestWithMessages(IEnumerable<Message> responseMessages)
        {
            this.responseMessages = responseMessages;
            this.IsCompleted = true;
            try
            {
                this.callback(this);
            }
            catch (Exception)
            {
            }
        }

2010/12/1 Слава Антонов <bed...@gmail.com>



--
Всего хорошего, Слава.

Слава Антонов

unread,
Dec 2, 2010, 12:14:59 AM12/2/10
to aspc...@googlegroups.com
No, my changes not fix the problem :(


2010/12/1 Слава Антонов <bed...@gmail.com>



--
Всего хорошего, Слава.

Neil Mosafi

unread,
Dec 4, 2010, 10:55:11 AM12/4/10
to aspComet
Sounds like some transport issues. What web server are you using? How
many clients are connecting? Where are the clients - any proxy server,
NAT, etc?

On Dec 2, 5:14 am, Слава Антонов <bedd...@gmail.com> wrote:
> No, my changes not fix the problem :(
>
> 2010/12/1 Слава Антонов <bedd...@gmail.com>
>
>
>
>
>
>
>
>
>
> > Hmm.
>
> > This is fix for my problem:
>
> > public void CompleteRequestWithMessages(IEnumerable<Message> responseMessages)
>
> >         {
> >             this.responseMessages = responseMessages;
> >             this.IsCompleted = true;
> >             try
>
> >             {
> >                 this.callback(this);
> >             }
> >             catch (Exception)
>
> >             {
> >             }
> >         }
>
> > 2010/12/1 Слава Антонов <bedd...@gmail.com>
>
> > Some info.
>
> >> I see "A first chance exception of type
> >> 'System.Net.Sockets.SocketException' occurred in System.dll" in VS Output
> >> window every time when client see "System: Request on channel
> >> /meta/connect failed: No message"
>
> >> I add breakpoint for this exception and VS shows me that it occurs in line
> >> "this.callback(this);" of
> >> public void CompleteRequestWithMessages(IEnumerable<Message> responseMessages)
> >> method in CometAsyncResult.cs.
>
> >> Exception message is "An existing connection was forcibly closed by the
> >> remote host"
>
> >> PS: I am using AspComet in ASP.NET MVC2 application.
>
> >> 2010/11/28 Слава Антонов <bedd...@gmail.com>
>
> >> Fine. Its working for me :)
>
> >>> But I have big ploblem with 'Handhake successful? True. System: Request
> >>> on channel /meta/connect failed: No message' error.
> >>> It occurs very frequent: after refresh client page, or after
> >>> connecting/disconnecting other client (especialy in IE8)
>
> >>> 2010/11/27 Neil Mosafi <nmos...@gmail.com>

Слава Антонов

unread,
Dec 5, 2010, 6:03:06 AM12/5/10
to aspc...@googlegroups.com
2010/12/4 Neil Mosafi <nmo...@gmail.com>

Sounds like some transport issues. What web server are you using? How
many clients are connecting? Where are the clients - any proxy server,
NAT, etc?

1) I am using Visual Studio 2010 integrated ASP. NET Developer server.
2) One or two clients. I see socket-exceptions with one client too.
3) Client are on same PC with ASP .NET Developer Server.

--
Всего хорошего, Слава.
Reply all
Reply to author
Forward
0 new messages