Important News

We have released Shinobi Life Online Pre-Alpha Version 1.1.0.0! This update features Earth Release: Earth Dome Jutsu, Aiming Mode and more! Try it out and tell us what you think.

User

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

Discord

Statistics

Members
Total Members: 54069
Latest: kubcis
New This Month: 11
New This Week: 3
New Today: 0
Stats
Total Posts: 55997
Total Topics: 3366
Most Online Today: 411
Most Online Ever: 4232
(January 14, 2020, 07:47:33)
Users Online
Members: 0
Guests: 389
Total: 391
Google (2)

Author Topic: Downloading image data from server to client  (Read 2671 times)

0 Members and 1 Guest are viewing this topic.

Offline peterp

  • Academy Student Poster
  • *
  • Posts: 1
  • Reputation Power: 2
  • peterp has no influence.
  • I'm new around here.
    • View Profile
Downloading image data from server to client
« on: March 07, 2016, 16:33:18 »
Syntax is Unity3d C#, networking is UNET.
This is useful for uploading and downloading images, for example custom clan banners etc.

Server side
Code: [Select]
const short DOWNLOAD_FILE = 1337;
void SendImageToClient(string path,int size, int connID)
{
    if (File.Exists(path))
     {
         byte[] fileData = File.ReadAllBytes(path);
         Texture2D tex = new Texture2D(size, size);
         tex.LoadImage(fileData);

          FileMessage fmsg = new FileMessage();
          fmsg.name = path;
          fmsg.size = size;
          fmsg.data = tex.EncodeToPNG();

         NetworkServer.SendToClient(connID, DOWNLOAD_FILE, fmsg);

     }
   
}
public class FileMessage : MessageBase
{
    public string name;
    public byte[] data;
    public int size;
}



[b]Client side[/b]



Code: [Select]
const short DOWNLOAD_FILE = 1337;
void Start()
{
    myClient.RegisterHandler(DOWNLOAD_FILE, OnDownloadFile);
}

void OnDownloadFile(NetworkMessage msg)
{

        FileMessage wmsg = msg.ReadMessage<FileMessage>();

        Texture2D tex = new Texture2D(wmsg.size, wmsg.size);
        tex.LoadImage(wmsg.data);
        //Do something with the downloaded image
}


  • Character Name: peterp

Offline Fraudulent

  • Pink Chunin Donator
  • Sennin Poster
  • **
  • Posts: 1 098
  • Reputation Power: 5
  • Fraudulent has no influence.
  • The Rose That Grew From Concrete
    • View Profile
  • Organization: BlackboxYoru
Re: Downloading image data from server to client
« Reply #1 on: March 07, 2016, 16:44:56 »
This probably means something to you @Vreg
internet sensation
also known as Snoopy
has a bigger dick than you

Offline Nas

  • Special Jonin Poster
  • ****
  • Posts: 343
  • Reputation Power: 3
  • Nas has no influence.
  • Gender: Male
  • meh....
    • View Profile
  • Organization:
Re: Downloading image data from server to client
« Reply #2 on: March 07, 2016, 17:33:22 »
*using my first year knowledge of coding* Uhmm Yeaa yea not bad
  • Character Name: Isei



Offline Boruto050202

  • Chunin Donator
  • Genin Poster
  • **
  • Posts: 94
  • Reputation Power: 2
  • Boruto050202 has no influence.
  • Gender: Male
  • I will protect my comrades at the cost of my life!
    • View Profile
  • Clan: Pawa-me


  • Organization: Roguhanta
Re: Downloading image data from server to client
« Reply #3 on: March 07, 2016, 20:27:08 »
My brain hurts ERMAGERD
  • Character Name: Rikai Pawa-me

 

Recent Topics

SHIPPING RESTRICTIONS EXTENSION FOR MAGENTO 2 by cynoinfotech
December 01, 2022, 10:43:00

OC by caleboftheleafvillage
November 30, 2022, 13:31:47

Capital One Login | Sign in to Online Banking Account by Erick453
November 24, 2022, 09:58:13

Shinobi Life Online Pre-Alpha Version 1.2.0.0 by SamuelEpperly
November 17, 2022, 15:48:01

Crashed when I log in by Jamezoar
November 17, 2022, 12:37:45

Uzumaki Clan by Jamezoar
November 17, 2022, 12:36:35

My Computer Freezes While Playing 'Shinobi Life Online' by Jamezoar
March 13, 2022, 17:04:23

The Lie That Never Lived: Shionbi Life Online by Ken
October 26, 2021, 00:28:55

I suggest we can do genjutsus by NinjaMirage
September 28, 2021, 13:01:13

Hug,slap,kiss or kill - Fourm game. by MarkKlaus3
September 17, 2021, 12:59:31

Top Posters

Mars
Posts: 2648
Reminance
Posts: 2246
Shivraj
Posts: 1610
m4r1us
Posts: 1298
Manuster
Posts: 1271
NinjaMirage
Posts: 1173
Nova
Posts: 1152
taigakun
Posts: 1099
Fraudulent
Posts: 1098
Konohuro
Posts: 1060