//save image of player 0 - ony an avatar (to WS) bool IMakaoGameHostService.UploadAvatarImagePlayer(MemoryStream input) { try { //deserialize request SaveAvatarRequest request = (SaveAvatarRequest)AvatarSerializerDeserializer.DeserializeFromStream(input); request.AvatarStream.Position = 0; //check if player exists if (CheckIfPlayerExists(request.PlayerNumber)) { //save image in temporary storage place Image img = System.Drawing.Image.FromStream(request.AvatarStream); img.Save(MakaoEngineHostDataPlaceholders.AvatarsLocation + GetProperAvatarName(request.PlayerNumber), ImageFormat.Png); InfoSenderClass Sender = new InfoSenderClass(); Sender.StartSendingInfoABoutChangeInCurrentPlayerList(); return(true); } else { return(false); } } catch (Exception ex) { //log if it turned to be impossible var logger = NLog.LogManager.GetCurrentClassLogger(); logger.Error("Saving image in the Makao Game Host faulted: " + ex.Message); return(false); } }
//method for sending avatar to the host (host will store it) public static bool SendAvatarToHost(MemoryStream avatarMemoryStream, int playerNumber, IMakaoGameHostService proxy) { //building game host service request object for sending an avatar SaveAvatarRequest addAvatarRequest = new SaveAvatarRequest() { AvatarStream = avatarMemoryStream, PlayerNumber = playerNumber, }; //and serializing it MemoryStream requestSerialized = EngineHost.DataPlaceholders.AvatarSerializerDeserializer.SerializeToStream(addAvatarRequest); requestSerialized.Position = 0; //uploading an avatar image bool streamSuccess = proxy.UploadAvatarImagePlayer(requestSerialized); return(streamSuccess); }