Set the Will for the client

 The will is a message that will be delivered by the server when the client dies.
 The Will must be set before establishing a connection to the server
178955
def set_will(topic, payload, retain = false, qos = 0)
      self.will_topic = topic
      self.will_payload = payload
      self.will_retain = retain
      self.will_qos = qos
    end
1165885
@Override
    public void onConnect(final Object newClient) {
        meta.commandsForDomainModel(new CommandsForDomainModelCallback() {
            @Override
            public void commandsReady(final List<Command> commands) {
                networkLayer.onConnectFinished(newClient);
                networkLayer.send(commands, newClient);
            }
        });
        // TODO networkLayer onConnectFinished(); javadoc that networklayer should then enable sendToAll for new
        // client.

    }
902973
def set_send_enable(self, setting):
        
        self._pebble.send_packet(DataLogging(data=DataLoggingSetSendEnable(enabled=setting)))
825331
function setClient() {
		var client = arguments[ 0 ],
			queries = Array.prototype.slice.apply( arguments );

		client.start( start )
			.end( end )
			.ms( ms )
			.arrays( arrays )
			.tsuids( tsuids )
			.annotations( annotations );

		queries.shift();
			
		client.queries.apply( client, queries );
	}
91428
def send(self, message, timeout=None, tries=3, future=None, callback=None, raw=False):
        '''
        
        '''
        if future is None:
            future = tornado.concurrent.Future()
            future.tries = tries
            future.attempts = 0
            future.timeout = timeout
            # if a future wasn't passed in, we need to serialize the message
            message = self.serial.dumps(message)
        if callback is not None:
            def handle_future(future):
                response = future.result()
                self.io_loop.add_callback(callback, response)
            future.add_done_callback(handle_future)
        # Add this future to the mapping
        self.send_future_map[message] = future

        if self.opts.get('detect_mode') is True:
            timeout = 1

        if timeout is not None:
            send_timeout = self.io_loop.call_later(timeout, self.timeout_message, message)
            self.send_timeout_map[message] = send_timeout

        if not self.send_queue:
            self.io_loop.spawn_callback(self._internal_send_recv)

        self.send_queue.append(message)

        return future
744823
void setLastMessage(AVIMMessage lastMessage) {
    if (null != lastMessage) {
      if (null == this.lastMessage) {
        this.lastMessage = lastMessage;
      } else {
        if(this.lastMessage.getTimestamp() <= lastMessage.getTimestamp()) {
          this.lastMessage = lastMessage;
        }
      }
    }
  }
812066
public function onBeforeWrite()
    {
        parent::onBeforeWrite();

        if (!$this->owner->FromDataFeed) {
            $client = CustomerClient::create($this->owner);

            if ($this->owner->isChanged() && FoxyStripeSetting::current_foxystripe_setting()->UseSingleSignOn) {
                $data = $client->putCustomer();

                $parts = explode('/', $data['_links']['self']['href']);

                $customerID = $parts[count($parts) - 1];

                $this->owner->Customer_ID = $customerID;
            } elseif ($this->owner->isChanged()) {
                $response = $client->putCustomer();
            }
        }
    }
1142097
def connect(self, version = 3, clean_session = 1, will = None):
        """"""
        self.clean_session = clean_session
        self.will          = None
        
        if will is not None:
            self.will = NyamukMsg(
                topic = will['topic'],
                # unicode text needs to be utf8 encoded to be sent on the wire
                # str or bytearray are kept as it is
                payload = utf8encode(will.get('message','')),
                qos = will.get('qos', 0),
                retain = will.get('retain', False)
            )

        #CONNECT packet
        pkt = MqttPkt()
        pkt.connect_build(self, self.keep_alive, clean_session, version = version)
        
        #create socket
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        if self.ssl:
            opts = {
                'do_handshake_on_connect': True,
                'ssl_version': ssl.PROTOCOL_TLSv1
            }
            opts.update(self.ssl_opts)
            #print opts, self.port

            try:
                self.sock = ssl.wrap_socket(self.sock, **opts)
            except Exception, e:
                self.logger.error("failed to initiate SSL connection: {0}".format(e))
                return NC.ERR_UNKNOWN

        nyamuk_net.setkeepalives(self.sock)
        
        self.logger.info("Connecting to server ....%s", self.server)
        err = nyamuk_net.connect(self.sock,(self.server, self.port))
        #print self.sock.cipher()
        
        if err != None:
            self.logger.error(err[1])
            return NC.ERR_UNKNOWN
        
        #set to nonblock
        self.sock.setblocking(0)
        
        return self.packet_queue(pkt)
356609
public Future<SendMessageResult> sendMessage(SendMessageRequest request,
                                                 AsyncHandler<SendMessageRequest, SendMessageResult> handler) {
        QueueBufferCallback<SendMessageRequest, SendMessageResult> callback = null;
        if (handler != null) {
            callback = new QueueBufferCallback<SendMessageRequest, SendMessageResult>(handler, request);
        }
        QueueBufferFuture<SendMessageRequest, SendMessageResult> future = sendBuffer.sendMessage(request, callback);
        future.setBuffer(this);
        return future;
    }
811706
def will_clear(self):
        
        self._will = False
        self._will_topic = ""
        self._will_payload = None
        self._will_qos = 0
        self._will_retain = False
887618
@Override
    public void prepare ( CommonServerMessageBlockRequest next ) {
        if ( isReceived() ) {
            ( (ServerMessageBlock2) next ).setTreeId(getTreeId());
        }
        super.prepare(next);
    }
683213
void setResult(Future<?> theFuture) { // d650178

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "setResult: " + Util.identity(theFuture) + " Future object: " + this);
        }

        // set result, we are done
        ivFuture = theFuture;
        done(); // F743-11774
    }
557311
def _set_client(self):
        """"""
        if self._client is None:
            if mongo_proxy:
                self._client = mongo_proxy.MongoProxy(
                    pymongo.MongoClient(self.connection_string),
                    logger=LOG)
            else:
                LOG.warning("MongoDBProxy not imported. AutoReconnect "
                            "is not enabled.")
                self._client = mongo_proxy.MongoProxy(
                    pymongo.MongoClient(self.connection_string),
                    logger=LOG)
            LOG.debug("Created new connection to MongoDB: %s",
                      self.safe_connection_string)
507520
private void sendRequest(Object request, ContextualFuture future) {
    if (open && connection.open) {
      long requestId = ++this.requestId;
      futures.put(requestId, future);
      connection.handleRequest(requestId, request);
    } else {
      future.context.executor().execute(() -> future.completeExceptionally(new ConnectException("connection closed")));
    }

    if (request instanceof ReferenceCounted) {
      ((ReferenceCounted<?>) request).release();
    }
  }
904634
def _should_send(self, rebuild, success, auto_canceled, manual_canceled):
        
        should_send = False

        should_send_mapping = {
            self.MANUAL_SUCCESS: not rebuild and success,
            self.MANUAL_FAIL: not rebuild and not success,
            self.MANUAL_CANCELED: not rebuild and manual_canceled,
            self.AUTO_SUCCESS: rebuild and success,
            self.AUTO_FAIL: rebuild and not success,
            self.AUTO_CANCELED: rebuild and auto_canceled
        }

        for state in self.send_on:
            should_send |= should_send_mapping[state]
        return should_send
1195534
def send(self, message):
        
        future = self.post(message)
        future.join()
        return future.result
907061
void deliverSingleDestinationMessage(Message msg, MessageID messageID) {
        synchronized (deliverySet) {
            long sequenceNumber = sequenceNumberManager.get();
            MessageInfo messageInfo = new MessageInfo(messageID, msg, sequenceNumber);
            messageInfo.updateAndMarkReadyToDeliver(sequenceNumber);
            deliverySet.add(messageInfo);
            notifyIfNeeded();
        }
    }