The following defines the chat service interface, as you can see the attribute for Service Contract.
There is also an Interface defined for the callback. This will be implemented on the client side, so that these methods are called from the Server(Service) and run on the client side.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Threading;
using ExampleService.ThreadArguments;
namespace ExampleService
{
/// <summary>
/// Inteface to be used for communications
///
/// Use the ServiceContractAttribute attribute on an interface (or class)
/// to define a service contract.
///
/// Then use the OperationContractAttribute attribute on one or more of the class (or interface)
/// methods to define the contract's service operations.
///
/// CallBackContract - Specify an interface in the CallbackContract property that represents
/// the required opposite contract in a two-way (or duplex) message exchange.
///
/// Use the SessionMode property to require bindings that support sessions between endpoints.
/// Setting the SessionMode property does not specify the type of session the contract requires,
/// only that it requires one.
/// </summary>
[ServiceContract(CallbackContract=typeof(IChatServiceCallback), SessionMode=SessionMode.Required)]
public interface IChatService
{
[OperationContract(IsOneWay = true)]
void Login(Participant user);
[OperationContract(IsOneWay = true)]
void CreateConversation(Participant originUser, Participant[] targetUsers);
[OperationContract(IsOneWay = true)]
void LeaveConversation(Guid conversationId, Participant currentUser);
[OperationContract(IsOneWay = true)]
void RemoveUserFromConversation(Guid conversationId, Participant removeUser);
[OperationContract(IsOneWay = true)]
void JoinUserToConversation(Guid conversationId, Participant newUser);
[OperationContract(IsOneWay = true)]
void EndConversation(Guid conversationId);
[OperationContract(IsOneWay = true)]
void AddStatementToConversation(Guid conversationId, Statement s);
[OperationContract(IsOneWay = true)]
void FindConversationsByKeyword(Guid srchId, string keywords);
[OperationContract(IsOneWay = true)]
void GetStatementsForConversation(Guid conversationId);
}
/// <summary>
/// Interface used for the async callback
/// </summary>
public interface IChatServiceCallback
{
[OperationContract(IsOneWay = true)]
void ReceiveSiteUsers(Participant[] users);
[OperationContract(IsOneWay = true)]
void StatusChanged(Participant user, Status newStatus);
[OperationContract(IsOneWay = true)]
void ConversationStarted(Guid conversationId, Participant owner, Participant[] participants);
[OperationContract(IsOneWay = true)]
void ConversationUpdated(Guid conversationId, Statement statement);
[OperationContract(IsOneWay = true)]
void ConversationEnded(Guid conversationId);
[OperationContract(IsOneWay = true)]
void ParticipantAddedToConversation(Guid conversationId, Participant participant);
[OperationContract(IsOneWay = true)]
void ParticipantLeftConversation(Guid conversationId, Participant participant);
[OperationContract(IsOneWay = true)]
void SearchResults(SearchResults results);
[OperationContract(IsOneWay = true)]
void StatementsForConversation(Statement[] statements);
}
}