Reputation: 46
this is my first question here so please do excuse if it's not really up to par with some of the more advanced questions. I'm mainly a Java developer however I recently started moving over the C# and I decided to pick up the Photon Networking Library in order to start implementing it with my Game that I'm creating using Unity3D as a Hobby.
The error that I'm receiving is as follows:
Error 1 'MMO.Photon.Server.PhotonServerHandler' does not implement interface member 'MMO.Framework.IHandler.HandleMeessage(MMO.Framework.IMessage, MMO.Photon.Server.PhotonServerPeer)' c:\users\boyz\documents\visual studio 2012\Projects\MMO.Framework\MMO.PhotonFramework\Server\PhotonServerHandler.cs 11 27 MMO.Photon
Which I don't really understand, as far as I'm aware it is implementing the interface, but I don't really understand how it works completely. So I'll just show you the classes that are at question here.
PhotonServerHandler is the class that the error derives from (or so it seems)
namespace MMO.Photon.Server
{
public abstract class PhotonServerHandler : IHandler<PhotonServerPeer>
{
public abstract MessageType Type { get; }
public abstract byte Code { get; }
public abstract int? SubCode { get; }
protected PhotonApplication Server;
public PhotonServerHandler(PhotonApplication application)
{
this.Server = application;
}
public bool HandleMessage(IMessage message, PhotonServerPeer serverPeer)
{
OnHandleMessage(message, serverPeer);
return true;
}
protected abstract bool OnHandleMessage(IMessage message, PhotonServerPeer serverPeer);
}
}
Then there's the IHandler which it's importing or inheriting from; However you word it in C#.
namespace MMO.Framework
{
public interface IHandler<T>
{
MessageType Type { get; }
byte Code { get; }
int? SubCode { get; }
bool HandleMeessage(IMessage message, T peer);
}
}
Then last but not least, we have the PhotonServerPeer class
namespace MMO.Photon.Server
{
public class PhotonServerPeer : ServerPeerBase
{
private readonly PhotonServerHandlerList handlerList;
protected readonly PhotonApplication Server;
#region Factory Method
public delegate PhotonServerPeer Factory(IRpcProtocol protocol, IPhotonPeer photonPeer);
#endregion
public PhotonServerPeer(IRpcProtocol protocol, IPhotonPeer photonPeer, PhotonServerHandlerList handlerList, PhotonApplication application) : base(protocol, photonPeer)
{
this.handlerList = handlerList;
this.Server = application;
}
protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
{
handlerList.HandleMessage(new PhotonRequest(operationRequest.OperationCode, operationRequest.Parameters.ContainsKey(Server.SubCodeParameterKey) ? (int?)Convert.ToInt32(operationRequest.Parameters[Server.SubCodeParameterKey]) : null, operationRequest.Parameters), this);
}
protected override void OnEvent(IEventData eventData, SendParameters sendParameters)
{
handlerList.HandleMessage(new PhotonEvent(eventData.Code, eventData.Parameters.ContainsKey(Server.SubCodeParameterKey) ? (int?)Convert.ToInt32(eventData.Parameters[Server.SubCodeParameterKey]) : null, eventData.Parameters), this);
}
protected override void OnOperationResponse(OperationResponse operationResponse, SendParameters sendParameters)
{
handlerList.HandleMessage(new PhotonResponse(operationResponse.OperationCode, operationResponse.Parameters.ContainsKey(Server.SubCodeParameterKey) ? (int?)Convert.ToInt32(operationResponse.Parameters[Server.SubCodeParameterKey]) : null, operationResponse.Parameters, operationResponse.DebugMessage, operationResponse.ReturnCode), this);
}
protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
{
//Server.ConnectionCollection.OnDisconnect(this);
}
}
}
I don't understand this error at all and It's been bothering me for a few hours now and I've tried everything I know how, I've been doing some googling and it might just be a very basic mistake which I've missed, but any help would be appreciated.
Upvotes: 1
Views: 2268
Reputation: 5876
In my case it was - "Class does not implement interface member INativeObject.Handle"
I just inherited my class with NSObject and issue got fixed.
Upvotes: 0
Reputation: 66449
You've currently got public bool HandleMessage
in PhotonServerHandler
, but the error is complaining that PhotonServerHandler
doesn't implement HandleMeessage
.
Looks like you've got a typo here:
public interface IHandler<T>
{
MessageType Type { get; }
byte Code { get; }
int? SubCode { get; }
bool HandleMeessage(IMessage message, T peer);
}
Rename HandleMeessage
to HandleMessage
and that particular error should disappear.
Upvotes: 5