How can I push a string from one client connected to a WCF service to another connected as well?
- by Sergio Tapia
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.