Voici ce que j'ai jusqu'à présent:Comment puis-je pousser une chaîne d'un client connecté à un service WCF à un autre également connecté?
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>();
}
}
}
Juste une simple chaîne passée d'un client à l'autre.