我正在尝试使用Silverlight和WCF Duplex创建一个基于turnbased的游戏。但我不能做一个登录页面。我被困住了,你的所有建议/帮助将不胜感激。
我对我的架构有一些疑问。
这是在IIS上托管我的(WCF轮询双工)GameService的好方法,还是应该创建一个控制台应用程序并提供方法?
我在主页上调用了2个方法。第一个LoginAsync和第一个完成后我正在调用第二个GetLoggedInPlayersAsync。但是我遇到了一些我无法弄清楚的错误。
这是我到目前为止所拥有的
[ServiceContract(Namespace="", CallbackContract=typeof(IGameClient), SessionMode=SessionMode.Required)]
// [DeliveryRequirements(RequireOrderedDelivery=true)]
public interface IGameService
{
[OperationContract(IsInitiating=true)]
bool Login(Player player);
[OperationContract(IsInitiating=false)]
void Logout();
[OperationContract]
IEnumerable<Player> GetLoggedInPlayers();
}
public interface IGameClient
{
[OperationContract(IsOneWay=true)]
void NotifyNewUserConnected(Player player);
}
public Home()
{
InitializeComponent();
client = Helpers.Extensions.GetGameServiceClient();
this.Loaded += new RoutedEventHandler(Home_Loaded);
client.GetLoggedInPlayersCompleted += new EventHandler<GetLoggedInPlayersCompletedEventArgs>(client_GetLoggedInPlayersCompleted);
client.NotifyNewUserConnectedReceived += new EventHandler<NotifyNewUserConnectedReceivedEventArgs>(client_NotifyNewUserConnectedReceived);
client.LoginCompleted += new EventHandler<LoginCompletedEventArgs>(client_LoginCompleted);
}
void Home_Loaded(object sender, RoutedEventArgs e)
{
// get the player
if (Player == null)
{
SignInWindow window = new SignInWindow();
window.Show();
Player = new Player
{
PlayerName = window.txtName.Text
};
window.Closed += new EventHandler(window_Closed);
}
}