How can I push a string from one client connected to a WCF service to another connected as well?

Posted by Sergio Tapia on Stack Overflow See other posts from Stack Overflow or by Sergio Tapia
Published on 2010-05-06T19:38:43Z Indexed on 2010/05/06 23:28 UTC
Read the original article Hit count: 240

Filed under:
|
|

Here's what I have so far:

IService:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace ServiceLibrary
{
    [ServiceContract(SessionMode = SessionMode.Allowed, CallbackContract = typeof(IServiceCallback))]
    public interface IService
    {
        [OperationContract(IsOneWay = false, IsInitiating = true, IsTerminating = false)]
        void Join(string userName);
    }

    interface IServiceCallback
    {        
        [OperationContract(IsOneWay = true)]
        void UserJoined(string senderName);
    }
}

Service:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace ServiceLibrary
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)]
    public class Service:IService
    {
        IServiceCallback callback = null;

        public void Join(string userName)
        {
            callback = OperationContext.Current.GetCallbackChannel<IServiceCallback>();

        }
    }
}

Just a simple string passed from one client to another.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf