示例#1
0
 public void sendFile(string eventName, LinkIOFile file)
 {
     throw new NotImplementedException();
 }
示例#2
0
 public void sendFile(string eventName, LinkIOFile file, List<User> receivers)
 {
     throw new NotImplementedException();
 }
示例#3
0
        public LinkIOFile sendFile(string eventName, Stream stream, String fileName, double validity)
        {
            LinkIOFile file = new LinkIOFile();

            int length = (int)stream.Length;
            int nbChunk = (int)Math.Ceiling((double)length / CHUNK_SIZE);
            int chunkID = 1;

            socket.Emit("upload.start", new AckImpl((fileID) =>
            {
                file.FileID = fileID.ToString();
                byte[] buffer = new byte[CHUNK_SIZE];

                int bytesRead;
                while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
                {
                    Console.WriteLine("Sending " + chunkID + "/" + nbChunk);
                    socket.Emit("upload.chunk", buffer);

                    chunkID++;
                }

                socket.Emit("upload.end");
                Console.WriteLine("Done.");
                
            }), fileName, eventName, nbChunk, validity);

            return file;
        }